In NumPy, the ma.getdata()
method is used to return the data of a given masked array as an ndarray.
The ma.getdata()
method takes the syntax below:
ma.getdata(a, subok=True)
The ma.getdata()
method takes the following parameter values:
a
(required): This is the input array.subok
(optional): This takes a boolean value. If set to False
, it will force the result to be a pure ndarray. When set to True
, it will return a subclass of the ndarray.The ma.getdata()
method returns an ndarray.
import numpy.ma as ma# creating a an arraya = ma.arange(8).reshape(4,2)# masking the element in the second row but the second columna[1, 1] = ma.masked# masking the elements in the third rowa[2, :] = ma.masked# printing the masked arrayprint(a)# printing the original arrayprint(ma.getdata(a))
numpy.ma
module.a
.