Numpy MaskedArray masked_outside() function | Python Last Updated : 17 Feb, 2020 Comments Improve Suggest changes Like Article Like Report numpy.MaskedArray.masked_outside() function is used to mask an array outside of a given interval. This function is a Shortcut to masked_where, where condition is True for arr outside the interval [v1, v2] (arr <v1)|(arr > v2). The boundaries v1 and v2 can be given in either order. Syntax : numpy.ma.masked_outside(arr, v1, v2, copy=True) Parameters: arr : [ndarray] Input array which we want to mask. v1, v2 : [int] Lower and upper range. copy : [bool] If True (default) make a copy of arr in the result. If False modify arr in place and return a view. Return : [ MaskedArray] The resultant array after masking. Code #1 : Python3 # Python program explaining # numpy.MaskedArray.masked_outside() method # importing numpy as geek # and numpy.ma module as ma import numpy as geek import numpy.ma as ma # creating input array in_arr = geek.array([1, 2, 3, -1, 2]) print ("Input array : ", in_arr) # applying MaskedArray.masked_outside methods mask_arr = ma.masked_outside(in_arr, -1, 1) print ("Masked array : ", mask_arr) Output: Input array : [ 1 2 3 -1 2] Masked array : [1 -- -- -1 --] Code #2 : Python3 # Python program explaining # numpy.MaskedArray.masked_outside() method # importing numpy as geek # and numpy.ma module as ma import numpy as geek import numpy.ma as ma # creating input array in_arr = geek.array([5e8, 3e-5, -45.0, 4e4, 5e2]) print ("Input array : ", in_arr) # applying MaskedArray.masked_outside methods mask_arr = ma.masked_outside(in_arr, 5e2, 5e8) print ("Masked array : ", mask_arr) Output: Input array : [ 5.0e+08 3.0e-05 -4.5e+01 4.0e+04 5.0e+02] Masked array : [500000000.0 -- -- 40000.0 500.0] Comment More infoAdvertise with us Next Article Numpy MaskedArray masked_outside() function | Python sanjoy_62 Follow Improve Article Tags : Machine Learning Python-numpy python Python Numpy-Masked Array Practice Tags : Machine Learningpython Similar Reads Numpy MaskedArray.masked_less() function | Python In many circumstances, datasets can be incomplete or tainted by the presence of invalid data. For example, a sensor may have failed to record a data, or recorded an invalid value. The numpy.ma module provides a convenient way to address this issue, by introducing masked arrays.Masked arrays are arra 2 min read Numpy MaskedArray.masked_where() function | Python In many circumstances, datasets can be incomplete or tainted by the presence of invalid data. For example, a sensor may have failed to record a data, or recorded an invalid value. The numpy.ma module provides a convenient way to address this issue, by introducing masked arrays.Masked arrays are arra 3 min read Numpy MaskedArray.masked_equal() function | Python In many circumstances, datasets can be incomplete or tainted by the presence of invalid data. For example, a sensor may have failed to record a data, or recorded an invalid value. The numpy.ma module provides a convenient way to address this issue, by introducing masked arrays.Masked arrays are arra 2 min read Numpy MaskedArray.masked_inside() function | Python In many circumstances, datasets can be incomplete or tainted by the presence of invalid data. For example, a sensor may have failed to record a data, or recorded an invalid value. The numpy.ma module provides a convenient way to address this issue, by introducing masked arrays.Masked arrays are arra 2 min read Numpy MaskedArray.prod() function | Python numpy.MaskedArray.prod() function is used to compute the product of the array elements over the given axis.Here masked elements are set to 1 internally for computation. Syntax : numpy.ma.prod(self, axis=None, dtype=None, out=None, keepdims=False) Parameters: arr : [ ndarray ] Input masked array. axi 3 min read Numpy MaskedArray.masked_greater() function | Python In many circumstances, datasets can be incomplete or tainted by the presence of invalid data. For example, a sensor may have failed to record a data, or recorded an invalid value. The numpy.ma module provides a convenient way to address this issue, by introducing masked arrays.Masked arrays are arra 2 min read Numpy MaskedArray.masked_invalid() function | Python In many circumstances, datasets can be incomplete or tainted by the presence of invalid data. For example, a sensor may have failed to record a data, or recorded an invalid value. The numpy.ma module provides a convenient way to address this issue, by introducing masked arrays.Masked arrays are arra 2 min read Numpy MaskedArray.masked_not_equal() function | Python In many circumstances, datasets can be incomplete or tainted by the presence of invalid data. For example, a sensor may have failed to record a data, or recorded an invalid value. The numpy.ma module provides a convenient way to address this issue, by introducing masked arrays.Masked arrays are arra 2 min read Numpy MaskedArray.masked_less_equal() function | Python In many circumstances, datasets can be incomplete or tainted by the presence of invalid data. For example, a sensor may have failed to record a data, or recorded an invalid value. The numpy.ma module provides a convenient way to address this issue, by introducing masked arrays.Masked arrays are arra 2 min read numpy.ma.MaskedArray.count() function - Python numpy.ma.MaskedArray.count() function count the non-masked elements of the array along the given axis. Syntax : numpy.ma.MaskedArray.count(self, axis=None, keepdims = no value) Parameters : axis : [None or int or tuple of ints, optional] Axis along which the count is performed. The default axis is N 2 min read Like