# W3cubDocs

/NumPy 1.17

`numpy.ma.masked_where(condition, a, copy=True)` [source]

Mask an array where a condition is met.

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

Parameters: `condition : array_like` Masking condition. When `condition` tests floating point values for equality, consider using `masked_values` instead. `a : array_like` Array to mask. `copy : bool` If True (default) make a copy of `a` in the result. If False modify `a` in place and return a view. `result : MaskedArray` The result of masking `a` where `condition` is True.

`masked_values`
`masked_equal`
Mask where equal to a given value.
`masked_not_equal`
Mask where `not` equal to a given value.
`masked_less_equal`
Mask where less than or equal to a given value.
`masked_greater_equal`
Mask where greater than or equal to a given value.
`masked_less`
Mask where less than a given value.
`masked_greater`
Mask where greater than a given value.
`masked_inside`
`masked_outside`
`masked_invalid`
Mask invalid values (NaNs or infs).

#### Examples

```>>> import numpy.ma as ma
>>> a = np.arange(4)
>>> a
array([0, 1, 2, 3])
fill_value=999999)
```

Mask array `b` conditional on `a`.

```>>> b = ['a', 'b', 'c', 'd']
fill_value='N/A',
dtype='<U1')
```

Effect of the `copy` argument.

```>>> c = ma.masked_where(a <= 2, a)
>>> c
fill_value=999999)
>>> c[0] = 99
>>> c
fill_value=999999)
>>> a
array([0, 1, 2, 3])
>>> c = ma.masked_where(a <= 2, a, copy=False)
>>> c[0] = 99
>>> c
fill_value=999999)
>>> a
array([99,  1,  2,  3])
```

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

```>>> a = np.arange(4)
>>> a = ma.masked_where(a == 2, a)
>>> a
fill_value=999999)
>>> b = np.arange(4)
>>> b = ma.masked_where(b == 0, b)
>>> b