bundles / numpy 2.4.4 / numpy / ma / core / masked_object
function
numpy.ma.core:masked_object
source: /numpy/ma/core.py :2247
Signature
def masked_object ( x , value , copy = True , shrink = True ) Summary
Mask the array x where the data are exactly equal to value.
Extended Summary
This function is similar to masked_values, but only suitable for object arrays: for floating point, use masked_values instead.
Parameters
x: array_likeArray to mask
value: objectComparison value
copy: {True, False}, optionalWhether to return a copy of
x.shrink: {True, False}, optionalWhether to collapse a mask full of False to nomask
Returns
result: MaskedArrayThe result of masking
xwhere equal tovalue.
Examples
import numpy as np import numpy.ma as ma food = np.array(['green_eggs', 'ham'], dtype=object) eat = ma.masked_object(food, 'green_eggs') eat fresh_food = np.array(['cheese', 'ham', 'pineapple'], dtype=object) eat = ma.masked_object(fresh_food, 'green_eggs') eatNote that `mask` is set to ``nomask`` if possible.
eat
See also
- masked_equal
Mask where equal to a given value (integers).
- masked_values
Mask using floating point equality.
- masked_where
Mask where a condition is met.
Aliases
-
numpy.ma.masked_object