Python | Numpy getmaskarray() method (original) (raw)
Last Updated : 19 Sep, 2019
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 by using numpy.getmaskarray()
method, we are able to get the masked matrix in the form of numpy array.
import
numpy.ma as ma
gfg
=
ma.masked_equal([[
1
,
2
], [
5
,
6
]],
5
)
print
(ma.getmaskarray(gfg))
Output :
array([[False False]
[True False]])
Example #2 :
import
numpy.ma as ma
gfg
=
ma.masked_equal([
11
,
12
,
13
,
14
,
15
],
12
)
print
(ma.getmaskarray(gfg))
Output :
array([False True False False False])
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
- 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
- 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
- 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 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__ 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__ 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.MaskedA 1 min read
- Python | Numpy MaskedArray.__mul__ numpy.ma.MaskedArray class is a subclass of ndarray designed to manipulate numerical arrays with missing data. With the help of Numpy MaskedArray.__mul__ we can multiply a particular value that is provided as a parameter in the MaskedArray.__mul__() method. Syntax: numpy.MaskedArray.__mul__ Return: 1 min read
- Python | numpy.array_split() method With the help of numpy.array_split() method, we can get the splitted array of having different dimensions by using numpy.array_split() method. Syntax : numpy.array_split() Return : Return the splitted array of one dimension. Example #1 : In this example we can see that by using numpy.array_split() m 1 min read
- Numpy MaskedArray.getdata() - Python numpy.ma.getdata() function is used return the data of a masked array as an ndarray. Return the data of arr as an ndarray if arr is a MaskedArray, else return arr as a ndarray or subclass if not. Syntax : numpy.ma.getdata(a, subok=True) Parameters : arr : [array_like] Input MaskedArray, alternativel 2 min read