Numpy MaskedArray.all() function | Python Last Updated : 27 Sep, 2019 Comments Improve Suggest changes Like Article Like Report 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 arrays that may have missing or invalid entries. numpy.MaskedArray.all() function returns True if all elements evaluate to True. Syntax : MaskedArray.all(axis=None, out=None, keepdims) Parameters: axis : [int or None] Axis or axes along which a logical AND reduction is performed. out : [ndarray, optional] A location into which the result is stored. -> If provided, it must have a shape that the inputs broadcast to. -> If not provided or None, a freshly-allocated array is returned. keepdims : [bool, optional] If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array. Return : [ndarray, bool] A new boolean or array is returned unless out is specified, in which case a reference to out is returned. Code #1 : Python3 # Python program explaining # numpy.MaskedArray.all() method # importing numpy as geek # and numpy.ma module as ma import numpy as geek import numpy.ma as ma # creating input array in_arr = geek.array([1, 2, 3, -1, 5]) print ("Input array : ", in_arr) # applying MaskedArray.all methods to input array out_arr = in_arr.all() print ("Output array : ", out_arr) # Now we are creating a masked array by # making third entry as invalid. mask_arr = ma.masked_array(in_arr, mask =[0, 0, 1, 0, 0]) print ("Masked array : ", mask_arr) # applying MaskedArray.all methods to mask array out_arr = mask_arr.all() print ("Output array : ", out_arr) Output: Input array : [ 1 2 3 -1 5] Output array : True Masked array : [1 2 -- -1 5] Output array : True Code #2 : Python3 # Python program explaining # numpy.MaskedArray.all() method # importing numpy as geek # and numpy.ma module as ma import numpy as geek import numpy.ma as ma # creating input array in_arr = geek.array([1, 2, 3, -1, 5]) print ("Input array : ", in_arr) # Now we are creating a masked array by # making all entry as invalid. mask_arr = ma.masked_array(in_arr, mask =[1, 1, 1, 1, 1]) print ("Masked array : ", mask_arr) # applying MaskedArray.all methods to mask array out_arr = mask_arr.all() print ("Output array : ", out_arr) Output: Input array : [ 1 2 3 -1 5] Masked array : [-- -- -- -- --] Output array : -- Comment More infoAdvertise with us Next Article Numpy MaskedArray.all() function | Python jana_sayantan Follow Improve Article Tags : Python Python-numpy Practice Tags : python Similar Reads Numpy MaskedArray.any() 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 MaskedArray.allequal() 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 MaskedArray.anom() 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.dot() function | Python numpy.MaskedArray.dot() function is used to calculate the dot product of two mask arrays. Syntax : numpy.ma.dot(arr1, arr2, strict=False) Parameters: arr1, arr2:[ ndarray] Inputs arrays. strict : [bool, optional] Whether masked data are propagated (True) or set to 0 (False) for the computation. Defa 3 min read Numpy MaskedArray.argmin() 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 MaskedArray.astype() 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.argmax() 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 MaskedArray.flatten() function | Python numpy.MaskedArray.flatten() function is used to return a copy of the input masked array collapsed into one dimension. Syntax : numpy.ma.flatten(order='C') Parameters: order : [âCâ, âFâ, âAâ, âKâ, optional] Whether to flatten in C (row-major), Fortran (column-major) order, or preserve the C/Fortran o 2 min read Numpy MaskedArray.argsort() 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 MaskedArray.average() function | Python numpy.MaskedArray.average() function is used to return the weighted average of array over the given axis. Syntax : numpy.ma.average(arr, axis=None, weights=None, returned=False) Parameters: arr :[ array_like] Input masked array whose data to be averaged. Masked entries are not taken into account in 3 min read Like