numpy.ma.compress_rowcols() function in Python Last Updated : 12 Nov, 2020 Comments Improve Suggest changes Like Article Like Report 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) Parameters : 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. Code #1: Python3 # Python program explaining # numpy.ma.compress_rowcols() function # importing numpy as geek import numpy as geek arr = geek.ma.array(geek.arange(6).reshape(2, 3), mask=[[1, 0, 0], [0, 0, 0]]) gfg = geek.ma.compress_rowcols(arr) print(gfg) Output: [[4 5]] Code #2: Python3 # Python program explaining # numpy.ma.compress_rowcols() function # importing numpy as geek import numpy as geek arr = geek.ma.array(geek.arange(6).reshape(2, 3), mask=[[1, 0, 0], [0, 0, 0]]) gfg = geek.ma.compress_rowcols(arr, 1) print(gfg) Output: [[1 2] [4 5]] Comment More infoAdvertise with us Next Article numpy.ma.compress_rowcols() function in Python C code_hunt Follow Improve Article Tags : Python Python-numpy Python numpy-arrayManipulation Practice Tags : python Similar Reads numpy.ma.compress_cols() function in Python Prerequisite: numpy This numpy inbuilt function suppresses whole columns that contain masked values in a 2-D array. Syntax: Â numpy.ma.compress_cols(arr) Parameters :Â arr : [array_like, MaskedArray] This parameter holds the array to operate on.The array must be a 2D array.If no array elements are ma 1 min read numpy.ma.mask_rowcols() function | Python In this numpy.ma.mask_rowcols() function, mask 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 0, only rows are masked. If axis is 1 or -1, only columns are masked. Synta 2 min read Numpy recarray.compress() function | Python In numpy, arrays may have a data-types containing fields, analogous to columns in a spreadsheet. An example is [(a, int), (b, float)], where each entry in the array is a pair of (int, float). Normally, these attributes are accessed using dictionary lookups such as arr['a'] and arr['b']. Record array 3 min read numpy.ma.mask_rows() function | Python In this numpy.ma.mask_rows() function, mask rows of a 2D array that contain masked values. This function is a shortcut to mask_rowcols with axis equal to 0. Syntax : numpy.ma.mask_rows(arr, axis = None) Parameters : arr : [array_like, MaskedArray] The array to mask. The result is a MaskedArray. axis 2 min read Numpy MaskedArray.compressed() function - Python numpy.MaskedArray.compressed() function return all the non-masked data as a 1-D array. Syntax : numpy.MaskedArray.compressed(self) Return : [ndarray] A new ndarray holding the non-masked data is returned. Code #1 : Python3 # Python program explaining # numpy.MaskedArray.compressed() function # impor 1 min read Like