Why are 3D numpy arrays printed the way they are (How are they ordered)? Why are 3D numpy arrays printed the way they are (How are they ordered)? numpy numpy

Why are 3D numpy arrays printed the way they are (How are they ordered)?


Synthesizing the comments into a proper answer:

First, take a look at np.zeros(10).reshape(5, 2). That's 5 rows of 2 columns, not 2 rows of 5 columns. Adding 3 at the front means 3 planes of 5 rows and 2 columns. What you're missing is that you new dimension is at the front, not the end. In mathematics, usually the extra dimensions are added at the end (Like extending an (x,y) with a z becomes (x,y,z). However, in computer science array dimensions are typically done this way. It reflects the way arrays are typically stored in row-major order in memory.