0 / 34

Invite others

Progress

0 / 34

Aggregation Functions

Crunch arrays:

a.sum()  a.mean()  a.min()  a.max()
a.argmax()  # index of max

For 2D: axis=1 → rows.

Why this matters

Aggregations turn raw grids into summaries: totals per store, average score per student, or the index of the best candidate. The axis argument is the same idea you saw for indexing—just applied to reduction.

Getting axis wrong is a classic bug; the diagram is the mental model to reach for.

ResourcesDocs, references & more — opens in a new tab
🎯 Your Task

Given sales = np.array([[100,150,200],[300,250,180],[90,310,270]]), sum per store (axis=1) → store_totals.

sales.sum(axis=1)
exercise.py
⌘⏎ run · ⌘← → nav
Output
Run your code to see output here.