Open In App

Python | Numpy MaskedArray.__eq__

Last Updated : 27 Mar, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

numpy.ma.MaskedArray class is a subclass of ndarray designed to manipulate numerical arrays with missing data. With the help of Numpy MaskedArray.__eq__ operator we can find that which element in an array is equal to the value which is provided in the parameter.

Syntax: numpy.MaskedArray.__eq__

Return: self==value

Example #1 :
In this example we can see that after applying MaskedArray.__eq__(), we get the simple boolean array that can tell us which element in an array is equal that of provided parameter.




# import the important module in python 
import numpy as np 
  
# make an array with numpy 
gfg = np.ma.array([1, 2, 3, 4, 5, 6]) 
  
# applying MaskedArray.__eq__() method 
print(gfg.__eq__(4)) 


Output:

[False False False  True False False]

 
Example #2:




# import the 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]]) 
  
# applying MaskedArray.__eq__() method 
print(gfg.__eq__(4)) 


Output:

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

Similar Reads

NumPy ndarray.__eq__() Method | Compare Array Values to Specific Value
The ndarray.__eq__() method of Numpy compares the values in ndarray to a specific value. It is useful to find which value in ndarray is equal to the given value. It will return you a NumPy array with a boolean type having only values True and False. Example C/C++ Code # import the important module in python import numpy as np # make an array with n
2 min read
Python - tensorflow.DeviceSpec.__eq__()
TensorFlow is open-source Python library designed by Google to develop Machine Learning models and deep learning neural networks. __eq__() is used to check the equality of two DeviceSpec objects. Syntax: tensorflow.DeviceSpec.__eq__( other ) Parameters: other: It is a DeviceSpec object. Returns: It returns True if DeviceSpec object specifications a
2 min read
Difference between "__eq__" VS "is" VS "==" in Python
There are various ways using which the objects of any type in Python can be compared. Python has "==" operator, "is" operator, and "__eq__" dunder method for comparing two objects of a class or to customize the comparison. This article explains the above said three operators and how they differ from each other. == operator The "==" operator compare
4 min read
Numpy MaskedArray.atleast_3d() function | Python
numpy.MaskedArray.atleast_3d() function is used to convert inputs to masked arrays with at least three dimension.Scalar, 1-dimensional and 2-dimensional arrays are converted to 3-dimensional arrays, whilst higher-dimensional inputs are preserved. Syntax : numpy.ma.atleast_3d(*arys) Parameters: arys:[ array_like] One or more input arrays. Return : [
3 min read
Numpy MaskedArray.atleast_1d() function | Python
numpy.MaskedArray.atleast_1d() function is used to convert inputs to masked arrays with at least one dimension.Scalar inputs are converted to 1-dimensional arrays, whilst higher-dimensional inputs are preserved. Syntax : numpy.ma.atleast_1d(*arys) Parameters: arys:[ array_like] One or more input arrays. Return : [ ndarray] An array, or list of arra
2 min read
Numpy MaskedArray.atleast_2d() function | Python
numpy.MaskedArray.atleast_2d() function is used to convert inputs to masked arrays with at least two dimension.Scalar and 1-dimensional arrays are converted to 2-dimensional arrays, whilst higher-dimensional inputs are preserved. Syntax : numpy.ma.atleast_2d(*arys) Parameters: arys:[ array_like] One or more input arrays. Return : [ ndarray] An arra
2 min read
Python | Numpy MaskedArray.__ne__
numpy.ma.MaskedArray class is a subclass of ndarray designed to manipulate numerical arrays with missing data. With the help of Numpy MaskedArray.__ne__ operator we can find that which element in an array is not equal to the value which is provided in the parameter. Syntax: numpy.MaskedArray.__ne__ Return: self!=value Example #1 ,: In this example
1 min read
Python | Numpy MaskedArray.__ge__
numpy.ma.MaskedArray class is a subclass of ndarray designed to manipulate numerical arrays with missing data. With the help of Numpy MaskedArray.__ge__ operator we can find that which element in an array is greater than or equal to the value which is provided in the parameter. Syntax: numpy.MaskedArray.__ge__ Return: self>=value Example #1 : In
1 min read
Python | Numpy MaskedArray.__le__
numpy.ma.MaskedArray class is a subclass of ndarray designed to manipulate numerical arrays with missing data. With the help of Numpy MaskedArray.__le__ operator we can find that which element in an array is less than or equal to the value which is provided in the parameter. Syntax: numpy.MaskedArray.__le__ Return: self<=value Example #1 : In th
1 min read
Python | Numpy MaskedArray.__gt__
numpy.ma.MaskedArray class is a subclass of ndarray designed to manipulate numerical arrays with missing data. With the help of Numpy MaskedArray.__gt__ operator we can find that which element in an array is greater than the value which is provided in the parameter. Syntax: numpy.MaskedArray.__gt__ Return: self>value. Example #1 : In this exampl
1 min read
Practice Tags :