numpy 1.22.4 Pypi GitHub Homepage
Other Docs
NotesParametersReturnsBackRef
filled(self, fill_value=None)

Notes

The result is not a MaskedArray!

Parameters

fill_value : array_like, optional

The value to use for invalid entries. Can be scalar or non-scalar. If non-scalar, the resulting ndarray must be broadcastable over input array. Default is None, in which case, the fill_value attribute of the array is used instead.

Returns

filled_array : ndarray

A copy of self with invalid entries replaced by fill_value (be it the function argument or the attribute of self ), or self itself as an ndarray if there are no invalid entries to be replaced.

Return a copy of self, with masked values filled with a given value. However, if there are no masked values to fill, self will be returned instead as an ndarray.

Examples

This example is valid syntax, but we were not able to check execution
>>> x = np.ma.array([1,2,3,4,5], mask=[0,0,1,0,1], fill_value=-999)
... x.filled() array([ 1, 2, -999, 4, -999])
This example is valid syntax, but we were not able to check execution
>>> x.filled(fill_value=1000)
array([   1,    2, 1000,    4, 1000])
This example is valid syntax, but we were not able to check execution
>>> type(x.filled())
<class 'numpy.ndarray'>

Subclassing is preserved. This means that if, e.g., the data part of the masked array is a recarray, filled returns a recarray:

This example is valid syntax, but we were not able to check execution
>>> x = np.array([(-1, 2), (-3, 4)], dtype='i8,i8').view(np.recarray)
... m = np.ma.array(x, mask=[(True, False), (False, True)])
... m.filled() rec.array([(999999, 2), ( -3, 999999)], dtype=[('f0', '<i8'), ('f1', '<i8')])
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

numpy.ma.core.mvoid.filled

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /numpy/ma/core.py#3733
type: <class 'function'>
Commit: