Aggregation and Axes
Unit ID: M08-U05 Estimated active time: 25-35 minutes
The axis tells NumPy which dimension to collapse.
learner_totals = study_minutes.sum(axis=1)
weekly_means = study_minutes.mean(axis=0)
overall_mean = study_minutes.mean()
If rows are learners and columns are weeks:
axis=1collapses columns and returns one result per learner;axis=0collapses rows and returns one result per week; and- no axis returns one result for the full array.
Do not memorise axis numbers without naming the result shape. Predict that shape first.
Practice: calculate weekly maximums, learner minimums, and the overall median. Write the expected shape before running each expression.
