Python | Numpy MaskedArray .__ mul__

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

Syntax: numpy.MaskedArray .__ mul__

Return: Multiply self by other, 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 .__ mul __ ().

# import important module in python

import numpy as np 

 
# make an array with NumPy

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

 
# applying the MaskedArray method .__ mul __ ()

print (gfg .__ mul __ ( 5 )) 

Exit :

 [5 10 15 20 25] 

Example # 2:

Exit:

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

# import 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 the MaskedArray method .__ mul __ ()

print (gfg .__ mul_ _ ( 5 ))