Python | Numpy MaskedArray .__ ior __ ()

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 .__ ior__ we can get the elements OR by the value provided as a parameter in the MaskedArray .__ ior __ () method.

Syntax: numpy.MaskedArray .__ ior __ ($ self, value, /)

Return: Return self | = value.

Example # 1:
In this example, we see that each element — it is OR by value, which is passed as a parameter in the MaskedArray method .__ ior __ ().

# import important module into python

import numpy as np 

 
# make an array with NumPy

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

 
# applying the MaskedArray method .__ ior __ ()

print (gfg .__ ior __ ( 2 ) ) 

 

Exit :

 [3 2 3 6 7] 

Example # 2:

# import important module in 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 .__ ior __ ()

print (gfg .__ ior __ ( 1 )) 

Exit:

 [[1 3 3 5 5 ] [7 5 5 3 3]] 




Get Solution for free from DataCamp guru