Python | Numpy MaskedArray .__ rpow__

Arrays | NumPy | Python Methods and Functions

numpy.ma.MaskedArray class is a subclass of ndarray for manipulating numeric arrays with missing data. With the Numpy method MaskedArray .__ pow__ we can force elements with the value specified as a parameter.

Syntax: numpy. MaskedArray .__ rpow__

Return: Raise other to the power self, masking the potential NaNs.

Example # 1:
In this example, we can see that after applying MaskedArray .__ rpow __ (), we can see that each item is powered with a value that is supplied as a parameter.

 
# 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 .__ pow __ () method

print (gfg .__ rpow __ ( 3 )) 

Exit:

 [3 9 27 81 243] 

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 , 5 ], 

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

 
# applying MaskedArray .__ rpow __ () method

print (gfg .__ pow __ ( 2 ) ) 

Exit:

 [[ 1 4 9 16 25] [36 25 16 9 4]] 




Get Solution for free from DataCamp guru