numpy.ma.compress_rowcols() function in Python
numpy.ma.compress_rowcols() function suppresses rows and columns that contain masked values in a 2-D array.
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.
Syntax : numpy.ma.compress_rowcols(arr, axis = None)
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course
arr : [array_like, MaskedArray] This parameter holds the array to operate on.The array must be a 2D array. If no array elements are masked, arr is interpreted as a MaskedArray with mask set to nomask.
axis : [int, optional] Axis along which to perform the operation. Default is None.
Return : Return the compressed array.
[[1 2] [4 5]]