bundles / numpy latest / numpy / ma / extras / compress_nd
function
numpy.ma.extras:compress_nd
source: build-install/usr/lib/python3.14/site-packages/numpy/ma/extras.py :841
Signature
def compress_nd ( x , axis = None ) Summary
Suppress slices from multiple dimensions which contain masked values.
Parameters
x: array_like, MaskedArrayThe array to operate on. If not a MaskedArray instance (or if no array elements are masked),
xis interpreted as a MaskedArray withmaskset tonomask.axis: tuple of ints or int, optionalWhich dimensions to suppress slices from can be configured with this parameter. - If axis is a tuple of ints, those are the axes to suppress slices from. - If axis is an int, then that is the only axis to suppress slices from. - If axis is None, all axis are selected.
Returns
compress_array: ndarrayThe compressed array.
Examples
import numpy as np arr = [[1, 2], [3, 4]] mask = [[0, 1], [0, 0]] x = np.ma.array(arr, mask=mask) np.ma.compress_nd(x, axis=0) np.ma.compress_nd(x, axis=1) np.ma.compress_nd(x)✓
Aliases
-
numpy.ma.compress_nd