bundles / numpy 2.5.0.dev0+git20251130.2de293a / numpy / ma / core / MaskedArray / compressed
function
numpy.ma.core:MaskedArray.compressed
source: build-install/usr/lib/python3.14/site-packages/numpy/ma/core.py:3937
Signature
def compressed(self)Summary
Return all the non-masked data as a 1-D array.
Returns
data: ndarrayA new ndarray holding the non-masked data is returned.
Notes
The result is not a MaskedArray!
Examples
import numpy as np x = np.ma.array(np.arange(5), mask=[0]*2 + [1]*3) x.compressed() type(x.compressed())N-D arrays are compressed to 1-D.
arr = [[1, 2], [3, 4]] mask = [[1, 0], [0, 1]] x = np.ma.array(arr, mask=mask) x.compressed()
Aliases
numpy.ma.MaskedArray.compressed