numpy.ma.notmasked_contiguous function | Python Last Updated : 22 Apr, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report numpy.ma.notmasked_contiguous() function find contiguous unmasked data in a masked array along the given axis. Syntax : numpy.ma.notmasked_contiguous(arr, axis = None) Parameters : arr : [array_like] The input array. axis : [int, optional] Axis along which to perform the operation. Default is None. Return : [list] A list of slices (start and end indexes) of unmasked indexes in the array. If the input is 2d and axis is specified, the result is a list of lists. Code #1 : Python3 # Python program explaining # numpy.ma.notmasked_contiguous() function # importing numpy as geek # and numpy.ma module as ma import numpy as geek import numpy.ma as ma arr = geek.arange(12).reshape((3, 4)) mask = geek.zeros_like(arr) mask[1:, :-1] = 1; mask[0, 1] = 1; mask[-1, 0] = 0 ma = geek.ma.array(arr, mask = mask) gfg = geek.ma.notmasked_contiguous(ma) print (gfg) Output : [slice(0, 1, None), slice(2, 4, None), slice(7, 9, None), slice(11, 12, None)] Code #2 : Python3 # Python program explaining # numpy.ma.notmasked_contiguous() function # importing numpy as geek # and numpy.ma module as ma import numpy as geek import numpy.ma as ma arr = geek.arange(12).reshape((3, 4)) mask = geek.zeros_like(arr) mask[1:, :-1] = 1; mask[0, 1] = 1; mask[-1, 0] = 0 ma = geek.ma.array(arr, mask = mask) gfg = geek.ma.notmasked_contiguous(ma, axis = 1) print (gfg) Output : [[slice(0, 1, None), slice(2, 4, None)], [slice(3, 4, None)], [slice(0, 1, None), slice(3, 4, None)]] Comment More infoAdvertise with us Next Article numpy.ma.MaskedArray.count() function - Python S sanjoy_62 Follow Improve Article Tags : Machine Learning Python-numpy python Python Numpy-Masked Array Practice Tags : Machine Learningpython Similar Reads numpy.ma.notmasked_edges() function | Python numpy.ma.notmasked_edges() function find the indices of the first and last unmasked values along an axis. Return None, if all values are masked. Otherwise, return a list of two tuples, corresponding to the indices of the first and last unmasked values respectively. Syntax : numpy.ma.notmasked_edges( 2 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.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.ma.MaskedArray.count() function - Python numpy.ma.MaskedArray.count() function count the non-masked elements of the array along the given axis. Syntax : numpy.ma.MaskedArray.count(self, axis=None, keepdims = no value) Parameters : axis : [None or int or tuple of ints, optional] Axis along which the count is performed. The default axis is N 2 min read numpy.ma.masked_all() function | Python numpy.ma.masked_all() function return an empty masked array of the given shape and dtype, where all the data are masked. Syntax : numpy.ma.masked_all(shape, dtype) Parameter : shape : [tuple] Shape of the required MaskedArray. dtype : [dtype, optional] Data type of the output. Return : [MaskedArray] 1 min read numpy.ma.is_masked() function | Python numpy.ma.is_masked() function determine whether input has masked values & accepts any object as input, but always returns False unless the input is a MaskedArray containing masked values. Syntax : numpy.ma.is_masked(arr) Parameters : arr : [array_like] Array to check for masked values. Return : 1 min read Like