ma.asarray(a, dtype=None, order=None)
Convert the input to a masked array of the given data-type.
No copy is performed if the input is already an
. If a is a subclass of
, a base class
is returned.
Parameters:aarray_likeInput data, in any form that can be converted to a masked array. This includes lists, lists of tuples, tuples, tuples of tuples, tuples of lists, ndarrays and masked arrays.
dtypedtype, optionalBy default, the data-type is inferred from the input data.
order{‘C’, ‘F’}, optionalWhether to use row-major (‘C’) or column-major (‘FORTRAN’) memory representation. Default is ‘C’.
Returns:outMaskedArrayMasked array interpretation of a.
Examples
>>> importnumpyasnp>>> x=np.arange(10.).reshape(2,5)>>> xarray([[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.MaskedArray'>