numpy.ma.masked_array.get_fill_value#
method
- ma.masked_array.get_fill_value()[source]#
The default value used to replace masked entries when filling the array.
This scalar is used by
filledwhen no explicit replacement value is provided. Settingfill_valuedoes not change the underlying data or the mask. Setting it toNonerestores the default value for the array’s data type.See also
filledReturn an ndarray with masked entries replaced.
set_fill_valueSet the filling value of a masked array.
Examples
>>> import numpy as np >>> x = np.ma.array([10, 20, 30], mask=[False, True, False], ... fill_value=-999) >>> x.filled() array([ 10, -999, 30]) >>> x.filled(fill_value=0) array([10, 0, 30]) >>> x.data array([10, 20, 30])
>>> 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.141592653589793)
Reset to default:
>>> x.fill_value = None >>> x.fill_value np.float64(1e+20)