The masked_inside()
function in NumPy is used to mask an array inside a given interval.
This is the syntax of the masked_inside()
function:
ma.masked_inside(x, v1, v2)
The masked_inside()
function takes the following parameter values:
x
: This is the input array.v1
and v2
: These represent the boundaries for which the values of the given array are to be masked. Both values are not excluded when masking.The masked_inside()
function returns a masked array with values that fall within the specified intervals that are masked.
# A code to illustrate the masked_inside() function# importing the necessary librariesimport numpy as npimport numpy.ma as ma# creating an input arraymy_array = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])# masking the values starting from 3 to 7mask_array =ma.masked_inside(my_array, 3, 7)print(mask_array)
my_array
.masked_greater_equal()
function to mask the values from 3
to 7
. We assign the result to a variable called mask_array
.mask_array
, to the console.