14/26
Part 3 of 4 · Picking entries out of a tableLearn

Picking things out of the table

This section uses the three-student table. The small numbers are the positions, counted from 0.

square, with its positions
square (3, 3)
test 1
0
test 2
1
test 3
2
0 Ana7080901 Ben50100602 Cal807075

Square brackets take one entry per axis: first the row, then the column. Counting starts at 0.

print(square[1])       # row 1: Ben
# column 2: test 3, for everyone
print(square[:, 2])
[ 50 100  60]
[90 60 75]

square[1] is Ben's row. square[:, 2] is test 3 for every student. The : means all of this axis, so [:, 2] reads as every row, column 2.