Thursday, December 11, 2025
HomeLanguagesPython | Numpy getmask() method

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.




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


Output :

[[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.getmask() method
print(ma.getmask(gfg))


Output :

[False True False False False]

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32440 POSTS0 COMMENTS
Milvus
105 POSTS0 COMMENTS
Nango Kala
6811 POSTS0 COMMENTS
Nicole Veronica
11950 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12023 POSTS0 COMMENTS
Shaida Kate Naidoo
6943 POSTS0 COMMENTS
Ted Musemwa
7193 POSTS0 COMMENTS
Thapelo Manthata
6889 POSTS0 COMMENTS
Umr Jansen
6880 POSTS0 COMMENTS