Python | Numpy MaskedArray .__ rmul__



numpy.ma.MaskedArray class is a subclass of ndarray for manipulating numeric arrays with missing data. With Numpy MaskedArray .__ rmul__ we can multiply a specific value that is supplied as a parameter in the MaskedArray .__ rmul __ () method.

Syntax: numpy.MaskedArray .__ rmul__

Return: Multiply others by self, and return a new masked array.

Example # 1:
In this example, we see that each element of the array is multiplied by the value specified as a parameter in the MaskedArray method .__ rmul __ ().

# import important module in python

import numpy as np 

 
# make an array with NumPy

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

 
# applying MaskedArray .__ rmul __ () method

print (gfg .__ rmul __ ( 3 )) 

Exit:

 [3 6 9 12 15] 

Example # 2:

Exit:

 [[5 10 15 20 25] [30 25 20 15 10]] 

# import an important module into python

import numpy as np 

 
# make an array with NumPy

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

[ 6 , 5 , 4 , 3 , 2 ]]) 

 
# applying MaskedArray. __ rmul __ () method

print (gfg .__ rmul __ ( 5 ))