This is a pre-release version (2.5.0.dev0+git20251130.2de293a). Go to latest (2.4.4)
{ } Raw JSON

bundles / numpy 2.5.0.dev0+git20251130.2de293a / numpy / ma / extras / compress_rowcols

function

numpy.ma.extras:compress_rowcols

source: build-install/usr/lib/python3.14/site-packages/numpy/ma/extras.py :899

Signature

def   compress_rowcols ( x axis = None )

Summary

Suppress the rows and/or columns of a 2-D array that contain masked values.

Extended Summary

The suppression behavior is selected with the axis parameter.

  • If axis is None, both rows and columns are suppressed.

  • If axis is 0, only rows are suppressed.

  • If axis is 1 or -1, only columns are suppressed.

Parameters

x : array_like, MaskedArray

The array to operate on. If not a MaskedArray instance (or if no array elements are masked), x is interpreted as a MaskedArray with mask set to nomask. Must be a 2D array.

axis : int, optional

Axis along which to perform the operation. Default is None.

Returns

compressed_array : ndarray

The compressed array.

Examples

import numpy as np
x = np.ma.array(np.arange(9).reshape(3, 3), mask=[[1, 0, 0],
                                                  [1, 0, 0],
                                                  [0, 0, 0]])
x
np.ma.compress_rowcols(x)
np.ma.compress_rowcols(x, 0)
np.ma.compress_rowcols(x, 1)

Aliases

  • numpy.ma.compress_rowcols