bundles / numpy 2.5.0.dev0+git20251130.2de293a / numpy / ma / core / where
function
numpy.ma.core:where
source: build-install/usr/lib/python3.14/site-packages/numpy/ma/core.py :7913
Signature
def where ( condition , x = <no value> , y = <no value> ) Summary
Return a masked array with elements from x or y, depending on condition.
Extended Summary
Parameters
condition: array_like, boolWhere True, yield
x, otherwise yieldy.x, y: array_like, optionalValues from which to choose.
x,yandconditionneed to be broadcastable to some shape.
Returns
out: MaskedArrayAn masked array with
maskedelements where the condition is masked, elements fromxwhereconditionis True, and elements fromyelsewhere.
Examples
import numpy as np x = np.ma.array(np.arange(9.).reshape(3, 3), mask=[[0, 1, 0], [1, 0, 1], [0, 1, 0]]) x np.ma.where(x > 5, x, -3.1416)
See also
- nonzero
The function that is called when x and y are omitted
- numpy.where
Equivalent function in the top-level NumPy module.
Aliases
-
numpy.ma.where