numpy.ma.compress_rowcols(x, axis=None)
[source]
Suppress the rows and/or columns of a 2-D array that contain masked values.
The suppression behavior is selected with the axis
parameter.
Parameters: |
x : array_like, MaskedArray The array to operate on. If not a MaskedArray instance (or if no array elements are masked), axis : int, optional Axis along which to perform the operation. Default is None. |
---|---|
Returns: |
compressed_array : ndarray The compressed array. |
>>> x = np.ma.array(np.arange(9).reshape(3, 3), mask=[[1, 0, 0], ... [1, 0, 0], ... [0, 0, 0]]) >>> x masked_array(data = [[-- 1 2] [-- 4 5] [6 7 8]], mask = [[ True False False] [ True False False] [False False False]], fill_value = 999999)
>>> np.ma.compress_rowcols(x) array([[7, 8]]) >>> np.ma.compress_rowcols(x, 0) array([[6, 7, 8]]) >>> np.ma.compress_rowcols(x, 1) array([[1, 2], [4, 5], [7, 8]])
© 2008–2017 NumPy Developers
Licensed under the NumPy License.
https://docs.scipy.org/doc/numpy-1.12.0/reference/generated/numpy.ma.compress_rowcols.html