Friday, June 12, 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
32515 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6897 POSTS0 COMMENTS
Nicole Veronica
12013 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12109 POSTS0 COMMENTS
Shaida Kate Naidoo
7019 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6976 POSTS0 COMMENTS
Umr Jansen
6963 POSTS0 COMMENTS