Numpy MaskedArray.allequal() 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.allequal() function return True if all entries of a and b are equal, using fill_value as a truth value where either or both are masked. Syntax : numpy.ma.allequal(arr1, arr2, fill_value=True) Parameters: arr1, arr2 : [array_like] Input arrays to compare. fill_value : [ bool, optional] Whether masked values in arr1 or arr2 are considered equal (True) or not (False). Return : [ bool]Returns True if the two arrays are equal within the given tolerance, False otherwise. If either array contains NaN, then False is returned. Code #1 : Python3 # Python program explaining # numpy.MaskedArray.allequal() method # importing numpy as geek # and numpy.ma module as ma import numpy as geek import numpy.ma as ma # creating 1st input array in_arr1 = geek.array([1e8, 1e-5, -15.0]) print ("1st Input array : ", in_arr1) # Now we are creating 1st masked array by making third entry as invalid. mask_arr1 = ma.masked_array(in_arr1, mask =[0, 0, 1]) print ("1st Masked array : ", mask_arr1) # creating 2nd input array in_arr2 = geek.array([1e8, 1e-5, 15.0]) print ("2nd Input array : ", in_arr2) # Now we are creating 2nd masked array by making third entry as invalid. mask_arr2 = ma.masked_array(in_arr2, mask =[0, 0, 1]) print ("2nd Masked array : ", mask_arr2) # applying MaskedArray.allequal method out_arr = ma.allequal(mask_arr1, mask_arr2, fill_value = False) print ("Output array : ", out_arr) Output: 1st Input array : [ 1.0e+08 1.0e-05 -1.5e+01] 1st Masked array : [100000000.0 1e-05 --] 2nd Input array : [1.0e+08 1.0e-05 1.5e+01] 2nd Masked array : [100000000.0 1e-05 --] Output array : False Code #2 : Python3 # importing numpy as geek # and numpy.ma module as ma import numpy as geek import numpy.ma as ma # creating 1st input array in_arr1 = geek.array([2e8, 3e-5, -45.0]) print ("1st Input array : ", in_arr1) # Now we are creating 1st masked array by making third entry as invalid. mask_arr1 = ma.masked_array(in_arr1, mask =[0, 0, 1]) print ("1st Masked array : ", mask_arr1) # creating 2nd input array in_arr2 = geek.array([2e8, 3e-5, 15.0]) print ("2nd Input array : ", in_arr2) # Now we are creating 2nd masked array by making third entry as invalid. mask_arr2 = ma.masked_array(in_arr2, mask =[0, 0, 1]) print ("2nd Masked array : ", mask_arr2) # applying MaskedArray.allequal method out_arr = ma.allequal(mask_arr1, mask_arr2, fill_value = True) print ("Output array : ", out_arr) Output: 1st Input array : [ 2.0e+08 3.0e-05 -4.5e+01] 1st Masked array : [200000000.0 3e-05 --] 2nd Input array : [2.0e+08 3.0e-05 1.5e+01] 2nd Masked array : [200000000.0 3e-05 --] Output array : True Comment More infoAdvertise with us Next Article Numpy MaskedArray.allequal() function | Python jana_sayantan Follow Improve Article Tags : Python Python-numpy Python numpy-arrayManipulation Practice Tags : python Similar Reads Numpy MaskedArray.all() 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 arr 3 min read Numpy MaskedArray.masked_equal() 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.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.atleast_2d() function | Python numpy.MaskedArray.atleast_2d() function is used to convert inputs to masked arrays with at least two dimension.Scalar and 1-dimensional arrays are converted to 2-dimensional arrays, whilst higher-dimensional inputs are preserved. Syntax : numpy.ma.atleast_2d(*arys) Parameters: arys:[ array_like] One 2 min read Numpy MaskedArray.atleast_1d() function | Python numpy.MaskedArray.atleast_1d() function is used to convert inputs to masked arrays with at least one dimension.Scalar inputs are converted to 1-dimensional arrays, whilst higher-dimensional inputs are preserved. Syntax : numpy.ma.atleast_1d(*arys) Parameters: arys:[ array_like] One or more input arr 2 min read Numpy MaskedArray.atleast_3d() function | Python numpy.MaskedArray.atleast_3d() function is used to convert inputs to masked arrays with at least three dimension.Scalar, 1-dimensional and 2-dimensional arrays are converted to 3-dimensional arrays, whilst higher-dimensional inputs are preserved. Syntax : numpy.ma.atleast_3d(*arys) Parameters: arys: 3 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.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.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.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 Like