numpy.ma.where() function - Python Last Updated : 05 May, 2020 Comments Improve Suggest changes Like Article Like Report numpy.ma.where() function return a masked array with elements from x or y, depending on condition. Syntax : numpy.ma.where(condition, x, y) Parameter : condition : [array_like, bool] Where True, yield x, otherwise yield y. x, y : [array_like, optional] Values from which to choose. x, y and condition need to be broadcastable to some shape. Return : [MaskedArray] An masked array with masked elements where the condition is masked, elements from x where condition is True, and elements from y elsewhere. Code #1 : Python3 # Python program explaining # numpy.ma.where() function # importing numpy as geek # and numpy.ma module as ma import numpy as geek import numpy.ma as ma x = geek.ma.array(geek.arange(4.).reshape(2, 2), mask =[[0, 1], [1, 0]]) gfg = geek.ma.where(x > 5, x, -3.1416) print (gfg) Output : [[-3.1416 --] [-- -3.1416]] Code #2 : Python3 # Python program explaining # numpy.ma.where() function # importing numpy as geek # and numpy.ma module as ma import numpy as geek import numpy.ma as ma x = geek.ma.array(geek.arange(9.).reshape(3, 3), mask =[[0, 1, 0], [1, 0, 1], [0, 1, 0]]) gfg = geek.ma.where(x > 5, x, -3.1416) print (gfg) Output : [[-3.1416 -- -3.1416] [-- -3.1416 --] [6.0 -- 8.0]] Comment More infoAdvertise with us Next Article numpy.ma.where() function - Python sanjoy_62 Follow Improve Article Tags : Machine Learning Python-numpy python Python Numpy-Masked Array Practice Tags : Machine Learningpython Similar Reads numpy.where() in Python We will explore the basics of numpy.where(), how it works, and practical use cases to illustrate its importance in data manipulation and analysis.Syntax of numpy.where()Syntax :numpy.where(condition[, x, y]) Parameters condition: A condition that tests elements of the array.x (optional): Values from 3 min read Numpy MaskedArray.masked_where() function | Python In many circumstances, datasets can be incomplete or tainted by the presence of invalid data. For example, a sensor may have failed to record a data, or recorded an invalid value. The numpy.ma module provides a convenient way to address this issue, by introducing masked arrays.Masked arrays are arra 3 min read numpy.ma.filled() function - Python numpy.ma.filled() function return input as an array with masked data replaced by a fill value. If arr is not a MaskedArray, arr itself is returned. If arr is a MaskedArray and fill_value is None, fill_value is set to arr.fill_value. Syntax : numpy.ma.filled(arr, fill_value = None) Parameters : arr : 1 min read numpy.ma.allclose() function - Python numpy.ma.allclose() function returns True if two arrays are element-wise equal within a tolerance. This function is equivalent to allclose except that masked values are treated as equal (default) or unequal, depending on the masked_equal argument. Syntax : numpy.ma.allclose(a, b, masked_equal = True 2 min read numpy.ma.make_mask() function | Python numpy.ma.make_mask() function is used to create a boolean mask from an array. This function can accept any sequence that is convertible to integers, or nomask. It does not require that contents must be 0s and 1s, values of 0 are interpreted as False, everything else as True. Return m as a boolean ma 2 min read numpy.ma.masked_all_like() function | Python numpy.ma.masked_all_like() function return an empty masked array of the same shape and dtype as the array arr, where all the data are masked. Syntax : numpy.ma.masked_all_like(arr) Parameter : arr : [ndarray] An array describing the shape and dtype of the required MaskedArray. Return : [MaskedArray] 1 min read numpy.find() in Python numpy.core.defchararray.find(arr, substring, start=0, end=None): Finds the lowest index of the sub-string in the specified range. Parameters: arr : array-like or string to be searched. substring : substring to search for. start, end : [int, optional] Range to search in. Returns : An integer array wi 1 min read numpy.ma.MaskedArray.nonzero() function - Python numpy.ma.MaskedArray.nonzero() function return the indices of unmasked elements that are not zero. This function returns a tuple of arrays, one for each dimension, containing the indices of the non-zero elements in that dimension. Syntax : numpy.ma.MaskedArray.nonzero(self) Return : [tuple] Indices 1 min read Numpy MaskedArray.masked_greater() function | Python In many circumstances, datasets can be incomplete or tainted by the presence of invalid data. For example, a sensor may have failed to record a data, or recorded an invalid value. The numpy.ma module provides a convenient way to address this issue, by introducing masked arrays.Masked arrays are arra 2 min read Numpy MaskedArray.masked_invalid() function | Python In many circumstances, datasets can be incomplete or tainted by the presence of invalid data. For example, a sensor may have failed to record a data, or recorded an invalid value. The numpy.ma module provides a convenient way to address this issue, by introducing masked arrays.Masked arrays are arra 2 min read Like