Compare students and registrations
Part 2 · three explanations
The lecture distinguishes people from repeated observations. This table repeats student IDs because each row is a course registration.
Week 1: rows, keys and joins, PDF pp. 32–39, 42–53
Your task
Compare the two tables. Predict whether student_id is unique in enrolments and choose which table belongs on the left.
Evidence to include
Cite enrolment row count and distinct student count. Explain why the counts differ.
Notebook questions and code
Read here; run in your downloaded notebook. Start with its setup cells and run in order. Use your own ID and outputs where requested.
Download Lab 1 notebookPart 2: Look at the second table
Run the next cell. Then compare it with students.
Predict first: Should student_id still be unique here? Why or why not?
Python · cell 10 — read here, run in your notebook
print(enrolments.head())
print("Is student_id unique in enrolments?", enrolments["student_id"].is_unique)
print("Number of enrolment rows:", len(enrolments))
print("Number of different students:", enrolments["student_id"].nunique())
print("Courses:", sorted(enrolments["course_code"].unique()))Explain after running
- What does one row in enrolments represent? Write one sentence.
- Why can student_id repeat in enrolments without being an error? Write one sentence.
- Which table should be on the left if your final table needs one row per course registration? Write one sentence.
Saved only in this browser. This note doesn’t fill in the downloaded notebook; “reviewed” is a personal checklist, not a grade.