Mask rows and/or columns of a 2D array that contain masked values.
Mask whole rows and/or columns of a 2D array that contain masked values. The masking behavior is selected using the axis parameter.
axis is None, rows and columns are masked.axis is 0, only rows are masked.axis is 1 or -1, only columns are masked.The array to mask. If not a MaskedArray instance (or if no array elements are masked), the result is a MaskedArray with mask set to nomask (False). Must be a 2D array.
Axis along which to perform the operation. If None, applies to a flattened version of the array.
A modified version of the input array, masked depending on the value of the axis parameter.
If input array a is not 2D.
See also
mask_rowsMask rows of a 2D array that contain masked values.
mask_colsMask cols of a 2D array that contain masked values.
masked_whereMask where a condition is met.
The input array’s mask is modified by this function.
>>> import numpy as np
>>> a = np.zeros((3, 3), dtype=int)
>>> a[1, 1] = 1
>>> a
array([[0, 0, 0],
[0, 1, 0],
[0, 0, 0]])
>>> a = np.ma.masked_equal(a, 1)
>>> a
masked_array(
data=[[0, 0, 0],
[0, --, 0],
[0, 0, 0]],
mask=[[False, False, False],
[False, True, False],
[False, False, False]],
fill_value=1)
>>> np.ma.mask_rowcols(a)
masked_array(
data=[[0, --, 0],
[--, --, --],
[0, --, 0]],
mask=[[False, True, False],
[ True, True, True],
[False, True, False]],
fill_value=1)
© 2005–2024 NumPy Developers
Licensed under the 3-clause BSD License.
https://numpy.org/doc/2.4/reference/generated/numpy.ma.mask_rowcols.html