Multi-axis indexing
What it is
One index per axis inside a single bracket: arr[i, j]. A slice in a position keeps that axis, an integer drops it.
Why it matters
arr[i][j] also works, but it builds an intermediate view for the row and then indexes that — slower, and it cannot be assigned to reliably. One bracket is the idiom.
In the real world: Reading one store's sales on one day from a stores-by-days grid, or a single pixel from a product image.
x = np.arange(12).reshape(3, 4)
x[1, 2] # 6 — a scalar
x[1] # row 1, shape (4,)
x[:, 2] # column 2, shape (3,) — the axis is dropped
x[:, 2:3] # column 2, shape (3, 1) — the axis is keptExpecting x[:, 2] to be a column. It is 1-D, so it broadcasts as a row in the next operation. Use x[:, 2:3] or x[:, 2, None] when you need the (n, 1) shape.