Lab 1: what you should be able to explain
The lab joins student information to course registrations, then compares recorded pass rates. Each pass result still belongs to a registration.
The four TODO replacements are students, one_student_table, 'study_mode', and 'programme'. Understand why each belongs there.
one_student_table = students
joined = enrolments.merge(
one_student_table[['student_id', 'programme', 'study_mode']],
on='student_id', how='left', validate='many_to_one'
)
pass_rate_by_mode = (
joined.groupby('study_mode')['passed']
.agg(n='size', pass_rate='mean')
.assign(pass_rate=lambda x: 100 * x['pass_rate'])
)
For a complete Boolean/0-1 outcome, its mean equals passes divided by registrations. size counts group rows; count counts nonmissing values. If passed has missing values, the mean excludes them while size includes them: explicitly report the two denominators. The Lab 1 code assumes the provided pass outcomes are complete.
The final reflection must explain why the programme with the highest pass rate is not automatically the best teaching programme: preparation, course selection, grading thresholds and missingness can differ. Your chart is a descriptive comparison of registrations, not an intervention evaluation.
Sources: W1 PDF pp. 3, 13-17, 22-30, 32-53, 57-60; L1 Parts 1-5.
many_to_one is the lecture's key rule in code. Unique student keys on the right prevent registrations from multiplying.
The mean of complete 0/1 outcomes is a rate. The denominator is course registrations, linking directly to the later lecture on counts and rates.
Changing groupby changes the comparison, not its causal strength. Course mix and preparation can still differ between programmes.
Practice problems
Supplementary study questions on the lecture concepts — not verbatim exam questions. Each answer counts toward spaced review.
1. Conceptual understanding
Definitions and distinctions.
For complete 0/1 pass outcomes, what is their mean?
If passed contains missing values, how do size and mean behave?
2. Application
Apply the concept to a case or calculation.
What is the pass rate for [1,0,1,1]?
For [1,0,1,missing], what are size and count?
3. Interpretation and limitations
Evaluate assumptions and justify conclusions.
What does groupby('programme') do before calculating rates?
Programme A has the highest observed rate. What can be said directly?
Explain it in writing
Self-checked, not marked. Write a few sentences, then compare with the example answer. Your writing is saved as you type.
Show an example answer
size counts all entries in the group. count counts nonmissing entries. With four rows and one missing result, size is 4 and count is 3.
Check: did you answer the question, use evidence or working, and avoid claiming more than the evidence supports?
Show an example answer
The groups may differ in preparation, course selection, grading thresholds or missing results. A descriptive difference alone does not measure a teaching effect.
Check: did you answer the question, use evidence or working, and avoid claiming more than the evidence supports?