Mask rows of a 2D array that contain masked values. This function is a shortcut to ``mask_rowcols`` with `axis` equal to 0. See Also -------- mask_rowcols : Mask rows and/or columns of a 2D array. masked_where : Mask where a condition is met. Examples --------
(a, axis=np._NoValue)
| 1122 | |
| 1123 | |
| 1124 | def mask_rows(a, axis=np._NoValue): |
| 1125 | """ |
| 1126 | Mask rows of a 2D array that contain masked values. |
| 1127 | |
| 1128 | This function is a shortcut to ``mask_rowcols`` with `axis` equal to 0. |
| 1129 | |
| 1130 | See Also |
| 1131 | -------- |
| 1132 | mask_rowcols : Mask rows and/or columns of a 2D array. |
| 1133 | masked_where : Mask where a condition is met. |
| 1134 | |
| 1135 | Examples |
| 1136 | -------- |
| 1137 | >>> import numpy as np |
| 1138 | >>> a = np.zeros((3, 3), dtype=np.int_) |
| 1139 | >>> a[1, 1] = 1 |
| 1140 | >>> a |
| 1141 | array([[0, 0, 0], |
| 1142 | [0, 1, 0], |
| 1143 | [0, 0, 0]]) |
| 1144 | >>> a = np.ma.masked_equal(a, 1) |
| 1145 | >>> a |
| 1146 | masked_array( |
| 1147 | data=[[0, 0, 0], |
| 1148 | [0, --, 0], |
| 1149 | [0, 0, 0]], |
| 1150 | mask=[[False, False, False], |
| 1151 | [False, True, False], |
| 1152 | [False, False, False]], |
| 1153 | fill_value=1) |
| 1154 | |
| 1155 | >>> np.ma.mask_rows(a) |
| 1156 | masked_array( |
| 1157 | data=[[0, 0, 0], |
| 1158 | [--, --, --], |
| 1159 | [0, 0, 0]], |
| 1160 | mask=[[False, False, False], |
| 1161 | [ True, True, True], |
| 1162 | [False, False, False]], |
| 1163 | fill_value=1) |
| 1164 | |
| 1165 | """ |
| 1166 | if axis is not np._NoValue: |
| 1167 | # remove the axis argument when this deprecation expires |
| 1168 | # NumPy 1.18.0, 2019-11-28 |
| 1169 | warnings.warn( |
| 1170 | "The axis argument has always been ignored, in future passing it " |
| 1171 | "will raise TypeError", DeprecationWarning, stacklevel=2) |
| 1172 | return mask_rowcols(a, 0) |
| 1173 | |
| 1174 | |
| 1175 | def mask_cols(a, axis=np._NoValue): |
no test coverage detected
searching dependent graphs…