Python | Numpy getmaskarray () method

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

Syntax: numpy.getmaskarray(array)

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

Example # 1:
In this example, we can see that using numpy.getmaskarray () we can get the masked matrix as a numpy array.

# NumPy import

import numpy.ma as ma

  

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

 
# using the numpy.getmaskarray () method

print (ma.getmaskarray (gfg))

Output:

array ([[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.getmaskarray () method

print (ma.getmaskarray (gfg))

Output:

array ([False True False False False])