Python | Numpy getmaskarray() method (original) (raw)

Last Updated : 19 Sep, 2019

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.

Python3 1=1 `

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 :

Python3 1=1 `

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])