Tables, rows, columns and keys
One row might be one student, one course registration, or one student in one week. Count rows only after you know what a row represents.
A CSV is a text representation of a table. A DataFrame is a table that code can manipulate. A column describes an attribute; a row describes one observational unit. The grain or row definition says exactly what that unit is. A key uniquely identifies it; a composite key combines columns.
| Course table | Slide-reported rows | One row and candidate key |
|---|---|---|
| students.csv | 1,200 | One student; student_id |
| enrolments.csv | 4,665 | One student-course registration; student_id + course_code if unique in the stated period |
| activity.csv | 16,165 | One student-week; student_id + week if the export has one record per pair |
| outcomes.csv | 1,200 | One student's early features and withdrawal outcome |
| feedback.csv | 732 | One text comment; comments need not equal distinct students |
| platform_daily.csv | 364 | One day of platform sessions |
| students_dirty.csv | 1,205 | A damaged student export; inspect extra records before treating them as people |
If repeated course attempts or terms exist, a registration key may also require term or attempt. A key is justified by the process and verified against the data, not guessed from a column name.
len(enrolments) counts registrations. enrolments['student_id'].nunique() counts distinct recorded IDs. Neither alone proves that every expected student is present; compare with the roster. Multiple registrations give some students more weight in a row-level average.
W1 illustrates this with part-time representation: approximately 11.9% of registration rows versus 14.4% of students. The 2.5 percentage-point difference comes from unequal numbers of registrations per student. More rows do not fix an incorrect counting unit.
Sources: W1 PDF pp. 3, 13-17, 22-30, 32-53, 57-60; L1 Parts 1-5.
The lecture defines a row and an identifier. Here you check that students has one row per person and choose the matching table.
The lecture distinguishes people from repeated observations. This table repeats student IDs because each row is a course registration.
The lecture's summary context becomes a denominator check: all student rows for a response rate, recorded ratings for an observed mean.
The lecture distinguishes copies, corrections and repeated events. The evidence packet supports removing R13, retaining R14 over R02, and flagging an invalid age value.
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.
What key fits one row per student per week?
A table has 740 registrations for 200 students. What does len(table) count?
2. Application
Apply the concept to a case or calculation.
One student takes the same course in two terms. Which key may be needed?
A table contains three weekly rows for each of four students. How many distinct students are there?
3. Interpretation and limitations
Evaluate assumptions and justify conclusions.
Does a unique student_id column prove every expected student is present?
A registration-level mean gives more weight to which students?
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
No. It might contain three weekly records for each student. Check the row definition and the intended key before removing anything.
Check: did you answer the question, use evidence or working, and avoid claiming more than the evidence supports?
Show an example answer
The same student might take the same course in another term or attempt. Add the relevant term or attempt field and check uniqueness at that full definition.
Check: did you answer the question, use evidence or working, and avoid claiming more than the evidence supports?