cfdm.Data.filled

Data.filled(fill_value=None, inplace=False)[source]

Replace masked elements with the fill value.

New in version (cfdm): 1.8.7.0

Parameters
fill_value: scalar, optional

The fill value. By default the fill returned by get_fill_value is used, or if this is not set then the netCDF default fill value for the data type is used (as defined by netCDF.fillvals).

inplace: bool, optional

If True then do the operation in-place and return None.

Returns
Data or None

The filled data, or None if the operation was in-place.

Examples

>>> d = cfdm.Data([[1, 2, 3]])
>>> print(d.filled().array)
[[1 2 3]]
>>> d[0, 0] = cfdm.masked
>>> print(d.filled().array)
[[-9223372036854775806                    2                    3]]
>>> d.set_fill_value(-99)
>>> print(d.filled().array)
[[-99   2   3]]
>>> print(d.filled(1e10).array)
[[10000000000           2           3]]