NumPy

Previous topic

numpy.ma.MaskedArray.diagonal

Next topic

numpy.ma.MaskedArray.item

This is documentation for an old release of NumPy (version 1.19). Read this page in the documentation of the latest stable release (version 2.2).

numpy.ma.MaskedArray.fill

method

MaskedArray.fill(value)

Fill the array with a scalar value.

Parameters
valuescalar

All elements of a will be assigned this value.

Examples

>>>
>>> a = np.array([1, 2])
>>> a.fill(0)
>>> a
array([0, 0])
>>> a = np.empty(2)
>>> a.fill(1)
>>> a
array([1.,  1.])