Python | Numpy MaskedArray .__ div__

Arrays | NumPy | Python Methods and Functions

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

Syntax: numpy.MaskedArray .__ div__

Return: Divide other into self, and return a new masked array.

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

# import an important module into python

import numpy as np 

 
# make an array with NumPy

gfg = np.ma.array ([ 22 , 33 , 44 , 55 , 77 ]) 

 
# applying the MaskedArray method .__ div __ ()

print (gfg .__ div __ ( 11 )) 

Exit :

 [2.0 3.0 4.0 5.0 7.0] 

Example # 2:

# import an important module in python

import numpy as np 

 
# make an array with NumPy

gfg = np.ma.array ([[ 10 , 20 , 30 , 40 , 50 ], 

[ 11 , 22 , 33 , 44 , 55 ]]) 

 
# applying the MaskedArray method .__ div __ ()

print ( gfg .__ div __ ( 5 )) 

Exit:

 [[2.0 4.0 6.0 8.0 10.0] [2.2 4.4 6.6 8.8 11.0]] 




Get Solution for free from DataCamp guru