numpy.ma.masked_not_equal#

ma.masked_not_equal(x, value, copy=True)[源]#

对不等于给定值的数组进行掩码。

此函数是 masked_where 的快捷方式,其中 condition = (x != value)。

另请参阅

masked_where

在满足条件处进行掩码。

示例

>>> import numpy as np
>>> import numpy.ma as ma
>>> a = np.arange(4)
>>> a
array([0, 1, 2, 3])
>>> ma.masked_not_equal(a, 2)
masked_array(data=[--, --, 2, --],
             mask=[ True,  True, False,  True],
       fill_value=999999)