Python | Numpy getmask () method

With the numpy.getmask() method we can get the masked numpy array matrix that shows the masked values ​​using numpy.getmask () .

Syntax: numpy.getmask(array)

Return: Return masked values ​​of a matrix.

Example # 1:

In this example, we can see that with numpy .getmask () we can get the masked array matrix.

# NumPy import

import numpy.ma as ma

 

gfg = ma.masked_equal ([[ 1 , 2 ], [ 5 , 6 ]], 5 )

 
# using the numpy.getmask () method

print (ma.getmask (gfg))

Output:

[[False False]
[ True False]]

Example # 2:

# NumPy import

import numpy.ma as ma

  

gfg = ma .masked_equal ([ 11 , 12 , 13 , 14 , 15 ], 12 )

 
# using the numpy.getmask () method

print (ma.getmask (gfg))

Output:

[False True False False False]