Python | Numpy MaskedArray.__sub__
numpy.ma.MaskedArray class is a subclass of ndarray designed to manipulate numerical arrays with missing data. With the help of Numpy MaskedArray.__sub__ we can subtract a particular value that is provided as a parameter in the MaskedArray.__sub__() method. Value will be subtracted from each and every element in a numpy array.
Return: Subtract others from self, and return a new masked array.
Example #1 :
In this example we can see that each and every element in an array is subtracted with the value given as a parameter in method MaskedArray.__sub__(). Remember one thing it wouldn’t work for double type values.
[ 6 17 18 19 20]
[[16 17 18 19 20] [21 20 19 18 17]]
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