numpy.ma.MaskedArray.get_fill_value#

方法

ma.MaskedArray.get_fill_value()[源代码]#

掩码数组的填充值是一个标量.当设置时,None 将根据数据类型设置为默认值.

示例

>>> import numpy as np
>>> for dt in [np.int32, np.int64, np.float64, np.complex128]:
...     np.ma.array([0, 1], dtype=dt).get_fill_value()
...
np.int64(999999)
np.int64(999999)
np.float64(1e+20)
np.complex128(1e+20+0j)
>>> x = np.ma.array([0, 1.], fill_value=-np.inf)
>>> x.fill_value
np.float64(-inf)
>>> x.fill_value = np.pi
>>> x.fill_value
np.float64(3.1415926535897931)

重置为默认值:

>>> x.fill_value = None
>>> x.fill_value
np.float64(1e+20)