Python | Numpy getmask() method

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

Syntax : numpy.getmask(array)

Return : Return masked values of a matrix.



Example #1 :

In this example we can see that by using numpy.getmask() method, we are able to get the masked matrix of an array.

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output :

[[False False]
[ True False]]

Example #2 :

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output :

[False True False False False]



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.