numpy.MaskedArray.astype()
returns a copy of the MaskedArray cast to this new type.
Syntax:
numpy.MaskedArray.astype(newtype)
Parameters:
newtype: Type in which we want to convert the masked array.Return: [MaskedArray] A copy of self cast to input newtype. The returned record shape matches self.shape.
Code # 1:
|
Output:
Input array: [1 2 3 -1 5] Masked array: [1 2 - -1 5] int32 Output typecasted array: [1.0 2.0 - -1.0 5.0] float64
Code # 2:
|
Output :
Input array: [10.1 20.2 30.3 40.4 50.5] Masked array: [- 20.2 - 40.4 50.5 ] float64 Output typecasted array: [- 20 - 40 50] int32