The masked_greater_equal()
function in NumPy is used to mask an array where the value of the element of the array is greater than the specified value in the function.
This is the syntax of the masked_greater_equal()
function:
ma.masked_greater_equal(x, value)
The masked_greater_equal()
function takes the following parameter values:
x
: This is the input array. It is a required parameter value.value
: This is the value to which elements of the array are masked if they are greater than or equal to it. It is a required parameter value.The masked_greater_equal()
function returns a masked array.
# A code to illustrate the masked_greater_equal() 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 greater than 2mask_array =ma.masked_greater(my_array, 2)print(mask_array)
my_array.
masked_greater_equal()
function to mask the values greater than or equal to 2
in the input array. We assign the result to a variable called mask_array
.mask_array
, to the console.