python | Numpy masked_equal () method



Using the numpy.ma.masked_equal() method, we can get the value for the mask that is in the array using numpy.ma.masked_equal () .

Syntax: numpy.ma.masked_equal (array, value)

Return: Return the array after removing mask value.

Example # 1:

In this example, we see that with numpy.ma.masked_equal () we can get a new array after removing the mask value that is passed along with the array.

# NumPy import

import numpy.ma as ma

 
# using the numpy.ma.masked_equal () method

gfg = ma.masked_equal ([ 1 , 2 , 3 , 4 ], 3 )

 

print (gfg)

Exit:

[1 2 - 4]

Example # 2:

# NumPy import

import numpy.ma as ma

 
# using the numpy.ma.masked_equal () method

gfg = ma.masked_equal ([[ 1 , 2 , 3 , 4 ],

[ 6 , 7 , 8 , 9 ]], 6 )

 

print (gfg)

Logout:

[[1 2 3 4]
[- 7 8 9]]