numpy.ma.asarray(a, dtype=None, order=None)
[source]
Convert the input to a masked array of the given data-type.
No copy is performed if the input is already an ndarray
. If a
is a subclass of MaskedArray
, a base class MaskedArray
is returned.
Parameters: |
|
---|---|
Returns: |
|
See also
asanyarray
asarray
, but conserves subclasses.>>> x = np.arange(10.).reshape(2, 5) >>> x array([[0., 1., 2., 3., 4.], [5., 6., 7., 8., 9.]]) >>> np.ma.asarray(x) masked_array( data=[[0., 1., 2., 3., 4.], [5., 6., 7., 8., 9.]], mask=False, fill_value=1e+20) >>> type(np.ma.asarray(x)) <class 'numpy.ma.core.MaskedArray'>
© 2005–2019 NumPy Developers
Licensed under the 3-clause BSD License.
https://docs.scipy.org/doc/numpy-1.17.0/reference/generated/numpy.ma.asarray.html