Friday, May 29, 2026
HomeLanguagespython | Numpy masked_equal() method

python | Numpy masked_equal() method

With the help of numpy.ma.masked_equal() method, we can get the mask a value that in an array by using numpy.ma.masked_equal() method.

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

Return : Return the array after removing mask value.

Example #1 :

In this example we can see that by using numpy.ma.masked_equal() method, we are able to get the new array after removing mask value which is passed along with an array.




# import numpy
import numpy.ma as ma
  
# using numpy.ma.masked_equal() method
gfg = ma.masked_equal([1, 2, 3, 4], 3)
  
print(gfg)


Output :

[1 2 — 4]

Example #2 :




# import numpy
import numpy.ma as ma
  
# using numpy.ma.masked_equal() method
gfg = ma.masked_equal([[1, 2, 3, 4],
                       [6, 7, 8, 9]], 6)
  
print(gfg)


Output :

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

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

1 COMMENT

Most Popular

Dominic
32514 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6893 POSTS0 COMMENTS
Nicole Veronica
12012 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12107 POSTS0 COMMENTS
Shaida Kate Naidoo
7016 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6975 POSTS0 COMMENTS
Umr Jansen
6963 POSTS0 COMMENTS