def compress_rowcols(x, axis=None):
x = asarray(x)<EOL>if x.ndim != <NUM_LIT:2>:<EOL><INDENT>raise NotImplementedError("<STR_LIT>")<EOL><DEDENT>m = getmask(x)<EOL>if m is nomask or not m.any():<EOL><INDENT>return x._data<EOL><DEDENT>if m.all():<EOL><INDENT>return nxarray([])<EOL><DEDENT>(idxr, idxc) = (list(range(len(x))), list(range(x.shape[<NUM_LIT:1>])))<EOL>masked = m.nonzero()<EOL>if not axis:<EOL><INDENT>for i in np.unique(masked[<NUM_LIT:0>]):<EOL><INDENT>idxr.remove(i)<EOL><DEDENT><DEDENT>if axis in [None, <NUM_LIT:1>, -<NUM_LIT:1>]:<EOL><INDENT>for j in np.unique(masked[<NUM_LIT:1>]):<EOL><INDENT>idxc.remove(j)<EOL><DEDENT><DEDENT>return x._data[idxr][:, idxc]<EOL>
Suppress the rows and/or columns of a 2-D array that contain
masked values.

The suppression behavior is selected with the `axis` parameter.

- If axis is None, both rows and columns are suppressed.
- If axis is 0, only rows are suppressed.
- If axis is 1 or -1, only columns are suppressed.

Parameters
----------
axis : int, optional
    Axis along which to perform the operation. Default is None.

Returns
-------
compressed_array : ndarray
    The compressed array.

Examples
--------
>>> 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.extras.compress_rowcols(x)
array([[7, 8]])
>>> np.ma.extras.compress_rowcols(x, 0)
array([[6, 7, 8]])
>>> np.ma.extras.compress_rowcols(x, 1)
array([[1, 2],
       [4, 5],
       [7, 8]])