Open In App

Python | Numpy getmaskarray() method

Last Updated : 19 Sep, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

With the help of numpy.getmaskarray() method, we can get the masked matrix in the form numpy array which shows masked values by using numpy.getmaskarray() method.

Syntax : numpy.getmaskarray(array)

Return : Return masked values in the form of numpy array.

Example #1 :
In this example we can see that by using numpy.getmaskarray() method, we are able to get the masked matrix in the form of numpy array.




# import numpy
import numpy.ma as ma
  
gfg = ma.masked_equal([[1, 2], [5, 6]], 5)
  
# using numpy.getmaskarray() method
print(ma.getmaskarray(gfg))


Output :

array([[False False]
[True False]])

Example #2 :




# import numpy
import numpy.ma as ma
  
gfg = ma.masked_equal([11, 12, 13, 14, 15], 12)
  
# using numpy.getmaskarray() method
print(ma.getmaskarray(gfg))


Output :

array([False True False False False])


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads