You are viewing an older version (2.4.3). Go to latest (2.4.4)
{ } Raw JSON

bundles / numpy 2.4.3 / 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_like

Array to mask

value : object

Comparison value

copy : {True, False}, optional

Whether to return a copy of x.

shrink : {True, False}, optional

Whether to collapse a mask full of False to nomask

Returns

result : MaskedArray

The result of masking x where equal to value.

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')
eat
Note 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