NumPy

Previous topic

numpy.ma.MaskedArray.byteswap

Next topic

numpy.ma.MaskedArray.filled

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.compressed

method

MaskedArray.compressed(self)[source]

Return all the non-masked data as a 1-D array.

Returns
datandarray

A new ndarray holding the non-masked data is returned.

Notes

The result is not a MaskedArray!

Examples

>>>
>>> x = np.ma.array(np.arange(5), mask=[0]*2 + [1]*3)
>>> x.compressed()
array([0, 1])
>>> type(x.compressed())
<class 'numpy.ndarray'>