Thursday, January 22, 2026
HomeLanguagesPython | Numpy np.ma.common_fill_value() method

Python | Numpy np.ma.common_fill_value() method

With the help of np.ma.common_fill_value() method, we can get the common filling values from both the masked array if same by using np.ma.common_fill_value() method.

Syntax : np.ma.common_fill_value(array1, array2)
Return : Return the common filling value from both the arrays.

Example #1 :
In this example by using np.ma.common_fill_value() method, we are able to get the common filling values from both the masked arrays.




# import numpy
import numpy as np
  
x = np.ma.array([1, 2, 3], fill_value = 1)
y = np.ma.array([7, 8, 9], fill_value = 1)
  
# using np.ma.common_fill_value() method
gfg = np.ma.common_fill_value(x, y)
  
print(gfg)


Output :

1

Example #2 :




# import numpy
import numpy as np
  
x = np.ma.array([[1, 2], [2, 1]], fill_value = 2)
y = np.ma.array([[1, 5], [5, 1]], fill_value = 5)
  
# using np.ma.common_fill_value() method
gfg = np.ma.common_fill_value(x, y)
  
print(gfg)


Output :

None

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

Most Popular

Dominic
32475 POSTS0 COMMENTS
Milvus
119 POSTS0 COMMENTS
Nango Kala
6847 POSTS0 COMMENTS
Nicole Veronica
11977 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12064 POSTS0 COMMENTS
Shaida Kate Naidoo
6986 POSTS0 COMMENTS
Ted Musemwa
7220 POSTS0 COMMENTS
Thapelo Manthata
6933 POSTS0 COMMENTS
Umr Jansen
6912 POSTS0 COMMENTS