numpy.atleast_2d#

numpy.atleast_2d(*arys)[source]#

View inputs as arrays with at least two dimensions.

Parameters:
arys1, arys2, …array_like

One or more array-like sequences. Non-array inputs are convertedto arrays. Arrays that already have two or more dimensions arepreserved.

Returns:
res, res2, …ndarray

An array, or tuple of arrays, each witha.ndim>=2.Copies are avoided where possible, and views with two or moredimensions are returned.

Examples

>>>importnumpyasnp>>>np.atleast_2d(3.0)array([[3.]])
>>>x=np.arange(3.0)>>>np.atleast_2d(x)array([[0., 1., 2.]])>>>np.atleast_2d(x).baseisxTrue
>>>np.atleast_2d(1,[1,2],[[1,2]])(array([[1]]), array([[1, 2]]), array([[1, 2]]))
On this page