aNet.ai
Data Science/Learning path
0day streak0XP · Lv 1
← 1. Thinking Like a Data Scientist
Lesson 2.4 7 min · 275 words

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.

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.

Question 1 of 6 · +5 XP

What key fits one row per student per week?

Question 2 of 6 · +5 XP

A table has 740 registrations for 200 students. What does len(table) count?

2. Application

Apply the concept to a case or calculation.

Question 3 of 6 · Composite keys · +5 XP

One student takes the same course in two terms. Which key may be needed?

Question 4 of 6 · Distinct count · +5 XP

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.

Question 5 of 6 · Absent records · +5 XP

Does a unique student_id column prove every expected student is present?

Question 6 of 6 · Weighting · +5 XP

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?

Practice this topic
Saved in this browser as you type.
aNet.ai · Data Science Fundamentals · Weeks 1–5 · practice material, not an official examProgress saved in this browser