python | Numpy masked_equal() method (original) (raw)
Last Updated : 19 Sep, 2019
With the help of **numpy.ma.masked_equal()**
method, we can get the mask a value that in an array by using numpy.ma.masked_equal()
method.
Syntax :
numpy.ma.masked_equal(array, value)
Return : Return the array after removing mask value.
Example #1 :
In this example we can see that by using numpy.ma.masked_equal()
method, we are able to get the new array after removing mask value which is passed along with an array.
import
numpy.ma as ma
gfg
=
ma.masked_equal([
1
,
2
,
3
,
4
],
3
)
print
(gfg)
Output :
[1 2 — 4]
Example #2 :
import
numpy.ma as ma
gfg
=
ma.masked_equal([[
1
,
2
,
3
,
4
],
`` [
6
,
7
,
8
,
9
]],
6
)
print
(gfg)
Output :
[[1 2 3 4]
[– 7 8 9]]
Similar Reads
- Python | Numpy getmask() method With the help of numpy.getmask() method, we can get the masked matrix of numpy array which shows masked values by using numpy.getmask() method. Syntax : numpy.getmask(array) Return : Return masked values of a matrix. Example #1 : In this example we can see that by using numpy.getmask() method, we ar 1 min read
- Numpy MaskedArray.filled() method - Python numpy.MaskedArray.filled() function return a copy of self, with masked values filled with a given value. However, if there are no masked values to fill, self will be returned instead as an ndarray. Syntax : numpy.MaskedArray.filled(self, fill_value = None) Parameters : fill_value : [scalar, optional 2 min read
- Python | numpy.ma.ids() method With the help of numpy.ma.ids() method, we can get the address of masked array having data by using numpy.ma.ids() method. Syntax : numpy.ma.ids(array, mask) Return : Return the address of masked array. Example #1 : In this example we can see that by using numpy.ma.ids() method, we are able to get t 1 min read
- Numpy MaskedArray asarray() method | Python numpy.ma.asarray() function is used when we want to convert input to a masked array of the given data-type. No copy is performed if the input is already a ndarray. If arr is a subclass of MaskedArray, a base class MaskedArray is returned. Syntax : numpy.ma.asarray(arr, dtype=None, order=None) Parame 2 min read
- Python | Numpy getmaskarray() method With the help of numpy.getmaskarray() method, we can get the masked matrix in the form numpy array which shows masked values by using numpy.getmaskarray() method. Syntax : numpy.getmaskarray(array) Return : Return masked values in the form of numpy array. Example #1 : In this example we can see that 1 min read
- Python | numpy.assert_allclose() method With the help of numpy.assert_allclose() method, we can get the assertion errors when two array objects are not equal upto the mark by using numpy.assert_allclose(). Syntax : numpy.assert_allclose(actual_array, desired_array) Return : Return the Assertion error if two array objects are not equal. Ex 1 min read
- Python | Numpy MaskedArray.__mod__ What is a mask? A boolean array, used to select only certain elements for an operation # A mask example import numpy as np x = np.arange(5) print(x) mask = (x > 2) print(mask) x[mask] = -1 print(x) Output: [0 1 2 3 4] [False False False True True] [ 0 1 2 -1 -1] numpy.ma.MaskedArray class is a su 2 min read
- Python | Numpy np.mask_or() method With the help of np.mask_or() method, we can combine the two masks with logical OR operator by using np.mask_or() method. Syntax : np.mask_or(m1, m2) Return : Return the masks with logical OR operator. Example #1 : In this example we can see that by using np.mask_or() method, we are able to get the 1 min read
- Numpy MaskedArray asanyarray() method | Python numpy.ma.asanyarray() function is used when we want to convert input to a masked array, conserving subclasses. If arr is a subclass of MaskedArray, its class is conserved. No copy is performed if the input is already an ndarray. Syntax : numpy.ma.asanyarray(arr, dtype=None) Parameters : arr : [array 2 min read
- Python | Numpy MaskedArray.__eq__ 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__ Retu 1 min read