This is a pre-release version (2.5.0.dev0+git20251130.2de293a). Go to latest (2.4.4)
{ } Raw JSON

bundles / numpy 2.5.0.dev0+git20251130.2de293a / numpy / ma / core / filled

function

numpy.ma.core:filled

source: build-install/usr/lib/python3.14/site-packages/numpy/ma/core.py :619

Signature

def   filled ( a fill_value = None )

Summary

Return input as an ndarray, with masked values replaced by fill_value.

Extended Summary

If a is not a MaskedArray, a itself is returned. If a is a MaskedArray with no masked values, then a.data is returned. If a is a MaskedArray and fill_value is None, fill_value is set to a.fill_value.

Parameters

a : MaskedArray or array_like

An input object.

fill_value : array_like, optional.

Can be scalar or non-scalar. If non-scalar, the resulting filled array should be broadcastable over input array. Default is None.

Returns

a : ndarray

The filled array.

Examples

import numpy as np
import numpy.ma as ma
x = ma.array(np.arange(9).reshape(3, 3), mask=[[1, 0, 0],
                                               [1, 0, 0],
                                               [0, 0, 0]])
x.filled()
x.filled(fill_value=333)
x.filled(fill_value=np.arange(3))

See also

compressed

Aliases

  • numpy.ma.filled