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)
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.
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 :
[ 2 4 -999 8 -999]
Code #2 :
[-999 2 -999 4 5]
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course