原文:https://docs.scipy.org/doc/numpy/reference/generated/numpy.ma.masked_object.html
校对:(虚位以待)
numpy.ma.
masked_object
(x, value, copy=True, shrink=True)[source]屏蔽数组x,其中数据与值完全相等。
此函数类似于masked_values
,但仅适用于对象数组:对于浮点,使用masked_values
。
参数: | x:array_like
value:object
copy:{True,False},可选
shrink:{True,False},可选
|
---|---|
返回: | result:MaskedArray
|
也可以看看
masked_where
masked_equal
masked_values
例子
>>> import numpy.ma as ma
>>> food = np.array(['green_eggs', 'ham'], dtype=object)
>>> # don't eat spoiled food
>>> eat = ma.masked_object(food, 'green_eggs')
>>> print(eat)
[-- ham]
>>> # plain ol` ham is boring
>>> fresh_food = np.array(['cheese', 'ham', 'pineapple'], dtype=object)
>>> eat = ma.masked_object(fresh_food, 'green_eggs')
>>> print(eat)
[cheese ham pineapple]
注意,如果可能,掩码设置为nomask
。
>>> eat
masked_array(data = [cheese ham pineapple],
mask = False,
fill_value=?)