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.

filter_none

edit
close

play_arrow

link
brightness_4
code

# 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)

chevron_right


Output :

1



Example #2 :

filter_none

edit
close

play_arrow

link
brightness_4
code

# 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)

chevron_right


Output :

None

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.