Skip to course content
Free course

Python Foundations / Module 9 / Grouping and Summary Statistics

Module 9 lesson

Grouping and Summary Statistics

Unit ID: M09-U06 Estimated active time: 30-40 minutes

Group only after cleaning and validating the grouping field.

module_summary = (
    clean.groupby("module_id", as_index=False)
    .agg(records=("learner_id", "size"), total_minutes=("minutes", "sum"), mean_score=("score", "mean"))
)

Name each output so a reader knows the measure. Check group row counts against the clean table. Means ignore missing values by default, so report the non-missing count when interpretation depends on it.

Practice: produce one row per status with record count, total minutes, and number of non-missing scores. State one conclusion the summary supports and one it does not.