numpy.ma.compress_cols() function in Python Last Updated : 12 Nov, 2020 Comments Improve Suggest changes Like Article Like Report 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 masked, arr is interpreted as a MaskedArray with mask set to nomask. Return : Returns the compressed array. Below is the Implementation of the above function. Example 1: Python3 # importing numpy as geek import numpy as geek # defining an array with mask arr = geek.ma.array(geek.arange(6).reshape(2, 3), mask=[[1, 0, 0], [0, 0, 0]]) # applying mask to array elements gfg = geek.ma.compress_cols(arr) print(gfg) Output : [[1 2] [4 5]] Example 2: Python3 # importing numpy as geek import numpy as geek # defining array arr = geek.ma.array(geek.arange(9).reshape(3, 3), mask=[ [1, 0, 0], [1, 0, 0], [0, 0, 0]]) # applying mask to array elements gfg = geek.ma.compress_cols(arr) print(gfg) Output : [[1 2] [4 5] [7 8]] Comment More infoAdvertise with us Next Article numpy.ma.compress_cols() function in Python C code_hunt Follow Improve Article Tags : Python Python-numpy Python numpy-arrayManipulation Practice Tags : python Similar Reads 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 1 min read numpy.ma.mask_cols() function | Python In thisnumpy.ma.mask_cols() function, mask columns of a 2D array that contain masked values. This function is a shortcut to mask_rowcols with axis equal to 1. Syntax : numpy.ma.mask_cols(arr, axis = None) Parameters : arr : [array_like, MaskedArray] The array to mask. axis : [int, optional] Axis alo 1 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 numpy.ma.clump_masked() function | Python numpy.ma.clump_masked() function returns a list of slices corresponding to the masked clumps of a 1-D array. Syntax : numpy.ma.clump_masked(arr) Parameters : arr : [ndarray] A one-dimensional masked array. Return : [list of slice] The list of slices, one for each continuous region of masked elements 1 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 Like