On this page
numpy.ma.where
- numpy.ma.where(condition, x=<no value>, y=<no value>)[source]
- 
    Return a masked array with elements from xory, depending on condition.Note When only conditionis provided, this function is identical tononzero. The rest of this documentation covers only the case where all three arguments are provided.- Parameters
- 
      - conditionarray_like, bool
- 
        Where True, yield x, otherwise yieldy.
- x, yarray_like, optional
- 
        Values from which to choose. x,yandconditionneed to be broadcastable to some shape.
 
- Returns
- 
      - outMaskedArray
- 
        An masked array with maskedelements where the condition is masked, elements fromxwhereconditionis True, and elements fromyelsewhere.
 
 See also - numpy.where
- 
       Equivalent function in the top-level NumPy module. 
- nonzero
- 
       The function that is called when x and y are omitted 
 Examples>>> x = np.ma.array(np.arange(9.).reshape(3, 3), mask=[[0, 1, 0], ... [1, 0, 1], ... [0, 1, 0]]) >>> x masked_array( data=[[0.0, --, 2.0], [--, 4.0, --], [6.0, --, 8.0]], mask=[[False, True, False], [ True, False, True], [False, True, False]], fill_value=1e+20) >>> np.ma.where(x > 5, x, -3.1416) masked_array( data=[[-3.1416, --, -3.1416], [--, -3.1416, --], [6.0, --, 8.0]], mask=[[False, True, False], [ True, False, True], [False, True, False]], fill_value=1e+20)
© 2005–2020 NumPy Developers
Licensed under the 3-clause BSD License.
 https://numpy.org/doc/1.19/reference/generated/numpy.ma.where.html