MCPcopy Index your code
hub / github.com/numpy/numpy / mask_rowcols

Function mask_rowcols

numpy/ma/extras.py:1035–1121  ·  view source on GitHub ↗

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. - If `axis` is None, rows *and* columns are masked. - If `axis` is

(a, axis=None)

Source from the content-addressed store, hash-verified

1033
1034
1035def mask_rowcols(a, axis=None):
1036 """
1037 Mask rows and/or columns of a 2D array that contain masked values.
1038
1039 Mask whole rows and/or columns of a 2D array that contain
1040 masked values. The masking behavior is selected using the
1041 `axis` parameter.
1042
1043 - If `axis` is None, rows *and* columns are masked.
1044 - If `axis` is 0, only rows are masked.
1045 - If `axis` is 1 or -1, only columns are masked.
1046
1047 Parameters
1048 ----------
1049 a : array_like, MaskedArray
1050 The array to mask. If not a MaskedArray instance (or if no array
1051 elements are masked), the result is a MaskedArray with `mask` set
1052 to `nomask` (False). Must be a 2D array.
1053 axis : int, optional
1054 Axis along which to perform the operation. If None, applies to a
1055 flattened version of the array.
1056
1057 Returns
1058 -------
1059 a : MaskedArray
1060 A modified version of the input array, masked depending on the value
1061 of the `axis` parameter.
1062
1063 Raises
1064 ------
1065 NotImplementedError
1066 If input array `a` is not 2D.
1067
1068 See Also
1069 --------
1070 mask_rows : Mask rows of a 2D array that contain masked values.
1071 mask_cols : Mask cols of a 2D array that contain masked values.
1072 masked_where : Mask where a condition is met.
1073
1074 Notes
1075 -----
1076 The input array's mask is modified by this function.
1077
1078 Examples
1079 --------
1080 >>> import numpy as np
1081 >>> a = np.zeros((3, 3), dtype=np.int_)
1082 >>> a[1, 1] = 1
1083 >>> a
1084 array([[0, 0, 0],
1085 [0, 1, 0],
1086 [0, 0, 0]])
1087 >>> a = np.ma.masked_equal(a, 1)
1088 >>> a
1089 masked_array(
1090 data=[[0, 0, 0],
1091 [0, --, 0],
1092 [0, 0, 0]],

Callers 4

test_mask_rowcolsMethod · 0.90
mask_rowsFunction · 0.85
mask_colsFunction · 0.85

Calls 5

getmaskFunction · 0.85
nonzeroMethod · 0.80
arrayFunction · 0.70
anyMethod · 0.45
copyMethod · 0.45

Tested by 2

test_mask_rowcolsMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…