numpy.atleast_3d() function is used when we want to Convert inputs to arrays with at least three dimension. Scalar, 1 and 2 dimensional inputs are converted to 3-dimensional arrays, whilst higher-dimensional inputs are preserved.
Input includes scalar, lists, lists of tuples, tuples, tuples of tuples, tuples of lists and ndarrays.
Syntax : numpy.atleast_3d(*arrays)
arrays1, arrays2, … : [array_like] One or more array-like sequences. Non-array inputs are converted to arrays. Arrays that already have three or more dimensions are preserved.
Return : An array, or list of arrays, each with arr.ndim >= 3. Copies are avoided where possible, and views with three or more dimensions are returned. For example, a 1-D array of shape (N, ) becomes a view of shape (1, N, 1), and a 2-D array of shape (M, N) becomes a view of shape (M, N, 1).
Code #1 : Working
Input number : 10 output 3d array from input number : [[]]
Code #2 : Working
Input list : [[2, 6, 10], [8, 12, 16]] output array : [[[ 2] [ 6] ] [[ 8]  ]]
Code #3 : Working
Input array : [[[ 0 1 2 3] [ 4 5 6 7] [ 8 9 10 11] [12 13 14 15]]] output array : [[[ 0 1 2 3] [ 4 5 6 7] [ 8 9 10 11] [12 13 14 15]]] True
- Important differences between Python 2.x and Python 3.x with examples
- Python | Set 4 (Dictionary, Keywords in Python)
- Python | Sort Python Dictionaries by Key or Value
- abs() in Python
- Python | a += b is not always a = a + b
- gcd() in Python
- pow() in Python
- SHA in Python
- zip() in Python
- SQL using Python | Set 1
- Any & All in Python
- chr() in Python
- try and except in Python
- Python Set | pop()
- max() and min() in Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.