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
- Python - Read blob object in python using wand library
- MySQL-Connector-Python module in Python
- Python | Convert list to Python array
- Important differences between Python 2.x and Python 3.x with examples
- Python | Index of Non-Zero elements in Python list
- Python | PRAW - Python Reddit API Wrapper
- Reading Python File-Like Objects from C | Python
- twitter-text-python (ttp) module - Python
- Python | Merge Python key values to list
- Python | Set 4 (Dictionary, Keywords in Python)
- Python | Add Logging to a Python Script
- Python | Add Logging to Python Libraries
- Python | Sort Python Dictionaries by Key or Value
- Python | Visualizing O(n) using Python
- zip() in Python
- Use of min() and max() in Python
- Python if else
- C Vs Python
- pow() 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 firstname.lastname@example.org. 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.