Friday, January 30, 2026
HomeLanguagesPython | Numpy MaskedArray.__imod__

Python | Numpy MaskedArray.__imod__

numpy.ma.MaskedArray class is a subclass of ndarray designed to manipulate numerical arrays with missing data. With the help of Numpy MaskedArray.__imod__ we can get every element in an array is operated on binary operator i.e mod(%). Remember we can use any type of values in an array and value for mod is applied as the parameter in MaskedArray.__imod__() method.

Syntax: numpy.MaskedArray.__imod__(other)

Return: Return self%=value.

Example #1 :
In this example we can see that value that we have passed through MaskedArray.__imod__() method is used to perform the mod operation with every element of an array.




# import the important module in python 
import numpy as np 
      
# make an array with numpy 
gfg = np.ma.array([1, 2.5, 3, 7, 5]) 
      
# applying MaskedArray.__imod__() method 
print(gfg.__imod__(2)) 


Output:

[1.0 0.5 1.0 1.0 1.0]

 
Example #2:




# import the important module in python 
import numpy as np 
      
# make an array with numpy 
gfg = np.ma.array([[14, 22, 31, 47, 54], 
                [64, 53.5, 44, 36, 21]]) 
      
# applying MaskedArray.__imod__() method 
print(gfg.__imod__(5)) 


Output:

[[4.0 2.0 1.0 2.0 4.0]
 [4.0 3.5 4.0 1.0 1.0]]
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
6986 POSTS0 COMMENTS
Ted Musemwa
7222 POSTS0 COMMENTS
Thapelo Manthata
6934 POSTS0 COMMENTS
Umr Jansen
6917 POSTS0 COMMENTS