cf.Data.masked_where

Data.masked_where(condition, inplace=False)[source]

Mask the data where a condition is met.

d.masked_where(condition) is equivalent to d.where(condition, cf.masked).

Performance

masked_where causes all delayed operations to be executed.

Added in version 3.16.3.

See also

mask, masked_values, where

Parameters:
condition: array_like

The masking condition. The data is masked where condition is True. Any masked values already in the data are also masked in the result.

inplace: bool, optional

If True then do the operation in-place and return None.

Returns:
inplace: bool, optional

If True then do the operation in-place and return None.

Returns:
Data or None

The result of masking the data, or None if the operation was in-place.

Examples

>>> d = cf.Data([1, 2, 3, 4, 5])
>>> e = d.masked_where([0, 1, 0, 1, 0])
>>> print(e.array)
[1 -- 3 -- 5]