numpy.ma.mask_rowcols#
- ma.mask_rowcols(a,axis=None)[source]#
Mask rows and/or columns of a 2D array that contain masked values.
Mask whole rows and/or columns of a 2D array that containmasked values. The masking behavior is selected using theaxis parameter.
Ifaxis is None, rowsand columns are masked.
Ifaxis is 0, only rows are masked.
Ifaxis is 1 or -1, only columns are masked.
- Parameters:
- aarray_like, MaskedArray
The array to mask. If not a MaskedArray instance (or if no arrayelements are masked), the result is a MaskedArray withmask setto
nomask(False). Must be a 2D array.- axisint, optional
Axis along which to perform the operation. If None, applies to aflattened version of the array.
- Returns:
- aMaskedArray
A modified version of the input array, masked depending on the valueof theaxis parameter.
- Raises:
- NotImplementedError
If input arraya 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.
Notes
The input array’s mask is modified by this function.
Examples
>>>importnumpyasnp>>>a=np.zeros((3,3),dtype=int)>>>a[1,1]=1>>>aarray([[0, 0, 0], [0, 1, 0], [0, 0, 0]])>>>a=np.ma.masked_equal(a,1)>>>amasked_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)