a = shape (2, 3)
Try
Spaces or commas between values · new line = new row · blank line = new 2-D layer (3-D array).
Starting Python… (first visit downloads ≈ 15 MB, then it is cached)
a.shape = ( 2 axis 0 rows,3 axis 1 columns )
- ndim
- 2 — number of entries in the shape (number of axes)
- size
- 6 — total elements: 2 × 3 = 6
1
2
3
4
5
6
- axis 0 rows · length 2
- axis 1 columns · length 3
Hover or focus a cell to see its index.
Reading the array
Every element has one index per axis — 2 numbers, because ndim is 2. The shape lists how long each axis is.
axis 0has length 2: moving along it changes the 1st index — you step between rows.axis 1has length 3: moving along it changes the 2nd index — you step between columns.
import numpy as np
a = np.array([[1, 2, 3],
[4, 5, 6]])
aOutput
Output appears here.