numpy.ma.MaskedArray.astype

MaskedArray.astype(newtype) [source]

Returns a copy of the MaskedArray cast to given newtype.

Returns:

output : MaskedArray

A copy of self cast to input newtype. The returned record shape matches self.shape.

Examples

>>> x = np.ma.array([[1,2,3.1],[4,5,6],[7,8,9]], mask=[0] + [1,0]*4)
>>> print(x)
[[1.0 -- 3.1]
 [-- 5.0 --]
 [7.0 -- 9.0]]
>>> print(x.astype(int32))
[[1 -- 3]
 [-- 5 --]
 [7 -- 9]]

© 2008–2017 NumPy Developers
Licensed under the NumPy License.
https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.ma.MaskedArray.astype.html