Python | Numpy MaskedArray .__ pow__

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 .__ pow__

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

Example # 1:
In this example, we can see that after applying MaskedArray .__ pow __ (), we can see that each element receives power 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 .__ pow __ ( 3 )) 

Exit:

 [1 8 27 64 125] 

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

print (gfg .__ pow __ ( 2 )) 

Exit:

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




Get Solution for free from DataCamp guru