Related Articles
Numpy MaskedArray.atleast_1d() function | Python
• Last Updated : 13 Oct, 2019

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 :

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
data=[[--, 2],
[3, --],
[5, -3]],
[False,  True],
[False, False]],
fill_value=999999)]

Code #2 :

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]]]

Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course

My Personal Notes arrow_drop_up