Python | Numpy MaskedArray .__ lt__



numpy.ma.MaskedArray class is a subclass of ndarray for manipulating numeric arrays with missing data. Using the Numpy operator MaskedArray .__ lt__ we can determine which element of the array is less than the value specified in the parameter.

Syntax : numpy.MaskedArray .__ lt__

Return: self & lt; value.

Example # 1:
In this example, we can see that after applying MaskedArray .__ lt __ () we get a simple boolean array that can tell us which element in the array is smaller than the supplied parameter.

# 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 ]) 

  
# applying the MaskedArray method .__ lt __ ( )

print (gfg .__ lt __ ( 4 )) 

Exit :

 [True True True False False False] 

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

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

< code class = "undefined spaces">  
# applying the MaskedArray method .__ lt __ ()

print (gfg .__ lt __ ( 4 )) 

Exit:

 [[True True False False False] [False False False True True True]]