Python | Numpy MaskedArray .__ rmod__



numpy.ma.MaskedArray class is a subclass of ndarray for manipulating numeric arrays with missing data. With Numpy MaskedArray .__ rmod__ , each element in the masked array works with a binary operator, i.e. mod (%). Remember that we can use any type of value in the array, and the value for mod is applied as a parameter in MaskedArray .__ rmod __ ().

Syntax: numpy. MaskedArray .__ rmod__

Return: Return value% self.

Example # 1:
We see that the value we passed through the MaskedArray .__ rmod __ () method is used to perform a mod operation on each element of the array.

# import important module in python

import numpy as np 

 
# make an array with NumPy

gfg = np.ma.array ([ 1 2.5 , 3 , 4.8 , 5 ]) 

  
# applying the MaskedArray method .__ rmod __ ( )

print (gfg .__ rmod __ ( 2 )) 

Exit :

 [0.0 2.0 2.0 2.0 2.0] 

Example # 2:

# import important module in python

import numpy as np 

 
# make an array with NumPy

gfg = np.ma.array ([ [ 1 , 2 , 3 , 4.45 , 5 ], 

[ 6 , 5.5 , 4 , 3 , 2.62 ]]) 

 
# applying the MaskedArray method .__ rmod __ ()

print (gfg .__ rmod __ ( 3 )) 

Output:

 [[0.0 1.0 0.0 3.0 3.0] [3.0 3.0 3.0 0.0 0.3799999999999999]]