Friday, January 30, 2026
HomeLanguagesPython | Numpy np.mask_or() method

Python | Numpy np.mask_or() method

With the help of np.mask_or() method, we can combine the two masks with logical OR operator by using np.mask_or() method.

Syntax : np.mask_or(m1, m2)
Return : Return the masks with logical OR operator.

Example #1 :
In this example we can see that by using np.mask_or() method, we are able to get the two masks with logical OR operator by using this method.




# import numpy and mask_or
import numpy as np
  
m1 = np.array([1, 1, 0, 1])
m2 = np.array([0, 0, 1, 1])
  
# using np.mask_or() method
gfg = np.ma.mask_or(m1, m2)
  
print(gfg)


Output :

[True True True True]

Example #2 :




# import numpy and mask_or
import numpy as np
  
m1 = np.array([1, 0, 0, 1, 0])
m2 = np.array([0, 0, 1, 1, 0])
  
# using np.mask_or() method
gfg = np.ma.mask_or(m1, m2)
  
print(gfg)


Output :

[True False True True False]

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

Most Popular

Dominic
32478 POSTS0 COMMENTS
Milvus
122 POSTS0 COMMENTS
Nango Kala
6849 POSTS0 COMMENTS
Nicole Veronica
11978 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12065 POSTS0 COMMENTS
Shaida Kate Naidoo
6987 POSTS0 COMMENTS
Ted Musemwa
7222 POSTS0 COMMENTS
Thapelo Manthata
6934 POSTS0 COMMENTS
Umr Jansen
6917 POSTS0 COMMENTS