numpy.ma.masked_array.tolist
method
-
masked_array.tolist(self, fill_value=None)
[source] -
Return the data portion of the masked array as a hierarchical Python list.
Data items are converted to the nearest compatible Python type. Masked values are converted to
fill_value
. Iffill_value
is None, the corresponding entries in the output list will beNone
.- Parameters
-
-
fill_valuescalar, optional
-
The value to use for invalid entries. Default is None.
-
- Returns
-
-
resultlist
-
The Python list representation of the masked array.
-
Examples
>>> x = np.ma.array([[1,2,3], [4,5,6], [7,8,9]], mask=[0] + [1,0]*4) >>> x.tolist() [[1, None, 3], [None, 5, None], [7, None, 9]] >>> x.tolist(-999) [[1, -999, 3], [-999, 5, -999], [7, -999, 9]]
© 2005–2020 NumPy Developers
Licensed under the 3-clause BSD License.
https://numpy.org/doc/1.19/reference/generated/numpy.ma.masked_array.tolist.html