2/26
Part 1 of 4 · Shapes and axesLearn
An array is a table with a shape
Every example in this lesson uses the same small table: students' scores on three tests. Here are two students.
import numpy as np
# Ana
scores = np.array([[70, 80, 90],
# Ben
[50, 100, 60]])
print(scores.shape)
(2, 3)
The shape is the size of the table: 2 rows and 3 columns. Each row is one student. Each column is one test.
scores (2, 3)down↓
test 1test 2test 3Ana708090Ben5010060
Each direction is an axis. Axis 0 runs down the rows, from student to student. Axis 1 runs across the columns, from test to test.
You can also count axes from the end. Axis -1 is the last one. In this table that's axis 1, the tests.