Numpy MaskedArray.atleast_1d() function | Python Last Updated : 13 Oct, 2019 Comments Improve Suggest changes Like Article Like Report 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 arrays. Return : [ ndarray] An array, or list of arrays, each with arr.ndim >= 1 Code #1 : Python3 # Python program explaining # numpy.MaskedArray.atleast_1d() method # importing numpy as geek # and numpy.ma module as ma import numpy as geek import numpy.ma as ma # creating input arrays in_arr1 = geek.array([[1, 2], [ 3, -1], [ 5, -3]]) print ("1st Input array : ", in_arr1) in_arr2 = geek.array(2) print ("2nd Input array : ", in_arr2) # Now we are creating masked array. # by making entry as invalid. mask_arr1 = ma.masked_array(in_arr1, mask =[[ 1, 0], [ 0, 1], [ 0, 0]]) print ("1st Masked array : ", mask_arr1) mask_arr2 = ma.masked_array(in_arr2, mask = 0) print ("2nd Masked array : ", mask_arr2) # applying MaskedArray.atleast_1d methods # to masked array out_arr = ma.atleast_1d(mask_arr1, mask_arr2) print ("Output masked array : ", out_arr) Output: 1st Input array : [[ 1 2] [ 3 -1] [ 5 -3]] 2nd Input array : 2 1st Masked array : [[-- 2] [3 --] [5 -3]] 2nd Masked array : 2 Output masked array : [masked_array( data=[[--, 2], [3, --], [5, -3]], mask=[[ True, False], [False, True], [False, False]], fill_value=999999), masked_array(data=[2], mask=[False], fill_value=999999)] Code #2 : Python3 # Python program explaining # numpy.MaskedArray.atleast_1d() 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([[[ 2e8, 3e-5]], [[ -45.0, 2e5]]]) print ("Input array : ", in_arr) # Now we are creating a masked array. # by making one entry as invalid. mask_arr = ma.masked_array(in_arr, mask =[[[ 1, 0]], [[ 0, 0]]]) print ("3D Masked array : ", mask_arr) # applying MaskedArray.atleast_1d methods # to masked array out_arr = ma.atleast_1d(mask_arr) print ("Output masked array : ", out_arr) Output: Input array : [[[ 2.0e+08 3.0e-05]] [[-4.5e+01 2.0e+05]]] 3D Masked array : [[[-- 3e-05]] [[-45.0 200000.0]]] Output masked array : [[[-- 3e-05]] [[-45.0 200000.0]]] Comment More infoAdvertise with us Next Article Numpy MaskedArray.atleast_1d() function | Python jana_sayantan Follow Improve Article Tags : Python Python-numpy Python numpy-arrayManipulation Practice Tags : python Similar Reads 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_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.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.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.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.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.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 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 Like