Python | Numpy MaskedArray .__ itruediv__

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 .__ itruediv__ we can specify a specific value that is provided as a parameter in the MaskedArray .__ itruediv __ () method.

Syntax: numpy.MaskedArray .__ itruediv __ (other)

Return: True divide self by other in-place.

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

# import important module in python

import numpy as np 

 
# make an array with NumPy

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

  
# applying MaskedArray .__ method itruediv __ ()

print (gfg .__ itruediv __ ( 2 )) 

Exit:

 [0.5 1.25 1.5 2.4 2.5]  

Example # 2:

# import an important module into 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 MaskedArray .__ it method ruediv __ ()

print (gfg .__ itruediv __ ( 5 )) 

Output:

 [[0.2 0.4 0.6 0.89 1.] [1.2 1.1 0.8 0.6 0.524]] 




Get Solution for free from DataCamp guru