Numpy MaskedArray.filled() method - Python Last Updated : 26 Mar, 2020 Comments Improve Suggest changes Like Article Like Report 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] The value to use for invalid entries, by default is None. If None, the fill_value attribute of the array is used instead. Return : filled_array : [ndarray] A copy of self with invalid entries replaced by fill_value or self itself as an ndarray if there are no invalid entries to be replaced. Code #1 : Python3 # Python program explaining # numpy.MaskedArray.filled() function # importing numpy as geek # and numpy.ma module as ma import numpy as geek import numpy.ma as ma arr = geek.ma.array([2, 4, 6, 8, 10], mask =[0, 0, 1, 0, 1], fill_value = -999) gfg = arr.filled() print(gfg) Output : [ 2 4 -999 8 -999] Code #2 : Python3 # Python program explaining # numpy.MaskedArray.filled() function # importing numpy as geek # and numpy.ma module as ma import numpy as geek import numpy.ma as ma arr = geek.ma.array([1, 2, 3, 4, 5], mask =[1, 0, 1, 0, 0], fill_value = -999) gfg = arr.filled() print(gfg) Output : [-999 2 -999 4 5] Comment More infoAdvertise with us Next Article Numpy MaskedArray.filled() method - Python sanjoy_62 Follow Improve Article Tags : Machine Learning Python-numpy python Python Numpy-Masked Array Practice Tags : Machine Learningpython Similar Reads 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 MaskedArray.__mod__ What is a mask? A boolean array, used to select only certain elements for an operation Python3 # 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 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.__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.MaskedArra 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 masked_equal() method 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.mask 1 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 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.__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.__lt__ numpy.ma.MaskedArray class is a subclass of ndarray designed to manipulate numerical arrays with missing data. With the help of Numpy MaskedArray.__lt__ operator we can find that which element in an array is less than the value which is provided in the parameter. Syntax: numpy.MaskedArray.__lt__ Ret 1 min read Like