1D Array: a1 = [1,2,3] 2D Array: a2 = [[1,2,3],[4,5,6],[7,8,9]] 3D Array: a3 = [ [ [1,2,3],[4,5,6],[7,8,9] ], [ [1,2,3],[4,5,6],[7,8,9] ], [ [1,2,3],[4,5,6],[7,8,9] ], ] An nD array is just a list of lists of lists n-levels down. Another way to think about is: How many indices do you need to refer to one specific element of the array? That "how many" is your n or dimensionality of the array: a1[0] # 1 index a2[0][1] # 2 indices a3[0][1][2] # 3 indices Answer from Big_Combination9890 on reddit.com
Top answer
1 of 6
71

You have a truncated array representation. Let's look at a full example:

>>> a = np.zeros((2, 3, 4))
>>> a
array([[[ 0.,  0.,  0.,  0.],
        [ 0.,  0.,  0.,  0.],
        [ 0.,  0.,  0.,  0.]],

       [[ 0.,  0.,  0.,  0.],
        [ 0.,  0.,  0.,  0.],
        [ 0.,  0.,  0.,  0.]]])

Arrays in NumPy are printed as the word array followed by structure, similar to embedded Python lists. Let's create a similar list:

>>> l = [[[ 0.,  0.,  0.,  0.],
          [ 0.,  0.,  0.,  0.],
          [ 0.,  0.,  0.,  0.]],

          [[ 0.,  0.,  0.,  0.],
          [ 0.,  0.,  0.,  0.],
          [ 0.,  0.,  0.,  0.]]]

>>> l
[[[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0]], 
 [[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0]]]

The first level of this compound list l has exactly 2 elements, just as the first dimension of the array a (# of rows). Each of these elements is itself a list with 3 elements, which is equal to the second dimension of a (# of columns). Finally, the most nested lists have 4 elements each, same as the third dimension of a (depth/# of colors).

So you've got exactly the same structure (in terms of dimensions) as in Matlab, just printed in another way.

Some caveats:

  1. Matlab stores data column by column ("Fortran order"), while NumPy by default stores them row by row ("C order"). This doesn't affect indexing, but may affect performance. For example, in Matlab efficient loop will be over columns (e.g. for n = 1:10 a(:, n) end), while in NumPy it's preferable to iterate over rows (e.g. for n in range(10): a[n, :] -- note n in the first position, not the last).

  2. If you work with colored images in OpenCV, remember that:

    2.1. It stores images in BGR format and not RGB, like most Python libraries do.

    2.2. Most functions work on image coordinates (x, y), which are opposite to matrix coordinates (i, j).

2 of 6
27

No need to go in such deep technicalities, and get yourself blasted. Let me explain it in the most easiest way. We all have studied "Sets" during our school-age in Mathematics. Just consider 3D numpy array as the formation of "sets".

x = np.zeros((2,3,4)) 

Simply Means:

2 Sets, 3 Rows per Set, 4 Columns

Example:

Input

x = np.zeros((2,3,4))

Output

Set # 1 ---- [[[ 0.,  0.,  0.,  0.],  ---- Row 1
               [ 0.,  0.,  0.,  0.],  ---- Row 2
               [ 0.,  0.,  0.,  0.]], ---- Row 3 
    
Set # 2 ----  [[ 0.,  0.,  0.,  0.],  ---- Row 1
               [ 0.,  0.,  0.,  0.],  ---- Row 2
               [ 0.,  0.,  0.,  0.]]] ---- Row 3

Explanation: See? we have 2 Sets, 3 Rows per Set, and 4 Columns.

Note: Whenever you see a "Set of numbers" closed in double brackets from both ends. Consider it as a "set". And 3D and 3D+ arrays are always built on these "sets".

Discussions

Create 3D array using Python - Stack Overflow
Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... And the sizes of the array should be the size of a variable I have. More on stackoverflow.com
🌐 stackoverflow.com
Initializing a 3D Numpy array with random values in Python - Python - Data Science Dojo Discussions
In the realm of data science and computational tasks, 3D Numpy arrays are a vital tool for managing multi-dimensional data. This thread explores the different techniques of initializing these arrays with random values, along with example codes. 1. Using the np.empty function: 2. Using the np.zeros ... More on discuss.datasciencedojo.com
🌐 discuss.datasciencedojo.com
1
0
January 30, 2023
What is 3D array in python?
1D Array: a1 = [1,2,3] 2D Array: a2 = [[1,2,3],[4,5,6],[7,8,9]] 3D Array: a3 = [ [ [1,2,3],[4,5,6],[7,8,9] ], [ [1,2,3],[4,5,6],[7,8,9] ], [ [1,2,3],[4,5,6],[7,8,9] ], ] An nD array is just a list of lists of lists n-levels down. Another way to think about is: How many indices do you need to refer to one specific element of the array? That "how many" is your n or dimensionality of the array: a1[0] # 1 index a2[0][1] # 2 indices a3[0][1][2] # 3 indices More on reddit.com
🌐 r/learnpython
9
8
February 19, 2024
Interpolating a 3d array in Python without loops

Any help with this ?? Please...

More on reddit.com
🌐 r/learnpython
1
2
October 27, 2014
🌐
W3Schools
w3schools.com › python › numpy › numpy_creating_arrays.asp
NumPy Creating Arrays
In this array the innermost dimension (5th dim) has 4 elements, the 4th dim has 1 element that is the vector, the 3rd dim has 1 element that is the matrix with the vector, the 2nd dim has 1 element that is 3D array and 1st dim has 1 element that is a 4D array. ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: sales@w3schools.com · If you want to report an error, or if you want to make a suggestion, send us an e-mail: help@w3schools.com · HTML Tutorial CSS Tutorial JavaScript Tutorial How To Tutorial SQL Tutorial Python Tutorial W3.CSS Tutorial Bootstrap Tutorial PHP Tutorial Java Tutorial C++ Tutorial jQuery Tutorial
🌐
GeeksforGeeks
geeksforgeeks.org › numpy › numpy-reshape-2d-to-3d-array
Numpy Reshape 2D To 3D Array - GeeksforGeeks
July 23, 2025 - NumPy is a powerful library in Python used for numerical operations and data analysis. Reshaping arrays is a common operation in NumPy, and it allows you to change the dimensions of an array without changing its data. In this article, we'll discuss how to reshape a 2D NumPy array into a 3D array.
🌐
Nipraxis
textbook.nipraxis.org › arrays_3d.html
Three-dimensional arrays — Practice and theory of brain imaging
The 3D array, as Numpy shows it, might not have an obvious resemblance to the image of the two planes shown above, but bear with us. ... The shape can be read as “two planes, each with 4 rows and 3 columns”, which corresponds to what is shown in the image of the planes above.
🌐
AskPython
askpython.com › home › multidimensional arrays in python: a complete guide
Multidimensional Arrays in Python: A Complete Guide - AskPython
February 27, 2023 - A 3-D (three-dimensional) array is mainly composed of an array of 2-D arrays. The rows, columns, and page elements can be viewed as primary components of a 3D array. We can visualize it as multiple tables comprising of rows and columns attached ...
🌐
Quora
quora.com › How-can-you-create-an-array-3D-in-Python
How to create an array 3D in Python - Quora
Answer: In Python, you can create a 3D array using lists or, preferably, NumPy arrays. NumPy is a powerful library for numerical operations, and it provides convenient functions for working with multi-dimensional arrays.
Find elsewhere
🌐
EDUCBA
educba.com › home › software development › software development tutorials › numpy tutorial › numpy 3d array
NumPy 3D array | Learn the Examples of NumPy 3D array
April 15, 2023 - To create a three-dimensional array in Python, we pass an object representing x by y by z, where x represents the nested lists, y represents the nested lists inside the x nested lists, and z represents the values inside each y nested list.
Address   Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-creating-3d-list
Python - Creating a 3D List - GeeksforGeeks
December 11, 2024 - In Python, 3D list represents a three dimensional data structure where we can organize elements in three axes (rows, columns, and depth).
🌐
Data Science Dojo
discuss.datasciencedojo.com › python
Initializing a 3D Numpy array with random values in Python - Python - Data Science Dojo Discussions
January 30, 2023 - In the realm of data science and computational tasks, 3D Numpy arrays are a vital tool for managing multi-dimensional data. This thread explores the different techniques of initializing these arrays with random values, along with example codes.
🌐
TutorialsPoint
tutorialspoint.com › python-program-to-create-3d-list
Python program to create 3D list.
In Python, A 3D list is also called a three-dimensional array (list of lists of lists). It can be visualized as a cube or a set of tables stacked together. It is commonly used to represent data with three indices. For example, a matrix of images (hei
🌐
Python Like You Mean It
pythonlikeyoumeanit.com › Module3_IntroducingNumpy › AccessingDataAlongMultipleDimensions.html
Accessing Data Along Multiple Dimensions in an Array — Python Like You Mean It
Let’s build up some intuition for arrays with a dimensionality higher than 2. The following code creates a 3-dimensional array: # a 3D array, shape-(2, 2, 2) >>> d3_array = np.array([[[0, 1], ... [2, 3]], ... ...
🌐
EDUCBA
educba.com › home › software development › software development tutorials › python tutorial › 3d arrays in python
3d Arrays in Python | How to Create,Insert And Remove 3D Array In Python
April 23, 2024 - Guide to 3d Arrays in Python. Here we discuss the introduction and how 3D Arrays are defined in Python along with creation, insertion arrays.
Address   Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
🌐
Medium
medium.com › @danfcarlson › arduino-sketches-decoded-1407545b1640
Arduino Sketches Decoded. Everything you wanted to know but were… | by Dan Carlson | Feb, 2026 | Medium
1 week ago - So I wrote my own. If you are interested in learning how to program Arduino boards to measure environmental data and to store that data for later analysis but you do not know where to start — this tutorial is for you.
🌐
Enthought
docs.enthought.com › mayavi › mayavi › mlab_3d_plotting_functions.html
3D Plotting functions for numpy arrays — mayavi 4.8.3 documentation
The mlab plotting functions take numpy arrays as input, describing the x, y, and z coordinates of the data. They build full-blown visualizations: they create the data source, filters if necessary, and add the visualization modules. Their behavior, and thus the visualization created, can be fine-tuned through keyword arguments, similarly to pylab.
🌐
W3Schools
w3schools.com › c › c_arrays_multi.php
C Multidimensional Arrays (Two-dimensional and more)
This creates a 3D array with: 2 blocks (first index) 4 rows per block (second index) 3 columns per row (third index) Multidimensional arrays are useful when your data is arranged in rows and columns, like a table, grid, or matrix. Each extra dimension adds another level of structure: 2D arrays (like int scores[3][4]) are great for storing things like scores, game boards, or spreadsheets ·