dask 2021.10.0

ParametersReturnsBackRef
masked_where(condition, a)

This docstring was copied from numpy.ma.masked_where.

Some inconsistencies with the Dask version may exist.

Return a as an array masked where :None:None:`condition` is True. Any masked values of a or :None:None:`condition` are also masked in the output.

Parameters

condition : array_like

Masking condition. When :None:None:`condition` tests floating point values for equality, consider using masked_values instead.

a : array_like

Array to mask.

copy : bool (Not supported in Dask)

If True (default) make a copy of a in the result. If False modify a in place and return a view.

Returns

result : MaskedArray

The result of masking a where :None:None:`condition` is True.

Mask an array where a condition is met.

See Also

masked_equal

Mask where equal to a given value.

masked_greater

Mask where greater than a given value.

masked_greater_equal

Mask where greater than or equal to a given value.

masked_inside

Mask inside a given interval.

masked_invalid

Mask invalid values (NaNs or infs).

masked_less

Mask where less than a given value.

masked_less_equal

Mask where less than or equal to a given value.

masked_not_equal

Mask where :None:None:`not` equal to a given value.

masked_outside

Mask outside a given interval.

masked_values

Mask using floating point equality.

Examples

This example is valid syntax, but we were not able to check execution
>>> import numpy.ma as ma  # doctest: +SKIP
... a = np.arange(4) # doctest: +SKIP
... a # doctest: +SKIP array([0, 1, 2, 3])
This example is valid syntax, but we were not able to check execution
>>> ma.masked_where(a <= 2, a)  # doctest: +SKIP
masked_array(data=[--, --, --, 3],
             mask=[ True,  True,  True, False],
       fill_value=999999)

Mask array :None:None:`b` conditional on a.

This example is valid syntax, but we were not able to check execution
>>> b = ['a', 'b', 'c', 'd']  # doctest: +SKIP
... ma.masked_where(a == 2, b) # doctest: +SKIP masked_array(data=['a', 'b', --, 'd'], mask=[False, False, True, False], fill_value='N/A', dtype='<U1')

Effect of the copy argument.

This example is valid syntax, but we were not able to check execution
>>> c = ma.masked_where(a <= 2, a)  # doctest: +SKIP
... c # doctest: +SKIP masked_array(data=[--, --, --, 3], mask=[ True, True, True, False], fill_value=999999)
This example is valid syntax, but we were not able to check execution
>>> c[0] = 99  # doctest: +SKIP
... c # doctest: +SKIP masked_array(data=[99, --, --, 3], mask=[False, True, True, False], fill_value=999999)
This example is valid syntax, but we were not able to check execution
>>> a  # doctest: +SKIP
array([0, 1, 2, 3])
This example is valid syntax, but we were not able to check execution
>>> c = ma.masked_where(a <= 2, a, copy=False)  # doctest: +SKIP
... c[0] = 99 # doctest: +SKIP
... c # doctest: +SKIP masked_array(data=[99, --, --, 3], mask=[False, True, True, False], fill_value=999999)
This example is valid syntax, but we were not able to check execution
>>> a  # doctest: +SKIP
array([99,  1,  2,  3])

When :None:None:`condition` or a contain masked values.

This example is valid syntax, but we were not able to check execution
>>> a = np.arange(4)  # doctest: +SKIP
... a = ma.masked_where(a == 2, a) # doctest: +SKIP
... a # doctest: +SKIP masked_array(data=[0, 1, --, 3], mask=[False, False, True, False], fill_value=999999)
This example is valid syntax, but we were not able to check execution
>>> b = np.arange(4)  # doctest: +SKIP
... b = ma.masked_where(b == 0, b) # doctest: +SKIP
... b # doctest: +SKIP masked_array(data=[--, 1, 2, 3], mask=[ True, False, False, False], fill_value=999999)
This example is valid syntax, but we were not able to check execution
>>> ma.masked_where(a == 3, b)  # doctest: +SKIP
masked_array(data=[--, 1, --, --],
             mask=[ True, False,  True,  True],
       fill_value=999999)
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

dask.array.ma.masked_values dask.array.ma.masked_invalid dask.array.ma.masked_equal dask.array.ma.masked_inside dask.array.ma.masked_outside

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /dask/array/ma.py#71
type: <class 'function'>
Commit: