cs-130 — The Duplicate Rows

FieldValue
idcs-130
difficultyIntermediate
topicsdeduplication, matching, missing values
lecturelecture-12
estimated time5-minute attempt + 10-minute discussion
prerequisiteslecture-09 (aggregation), lecture-13 preview (dictionaries)
objectivedesign a deduplication rule with an explicit key, conflict winner, and escalation path
solutionheld by the instructor; discussed after the attempt

Problem

Two registration exports must describe the same class of students.

Export A (from the old system, ids prefixed S-):

S-0007, Mia
S-0042, Omar
S-0117, Petra
S-0203, Quan
S-0311, Rosa

Export B (from the new system, ids unprefixed, newest last):

0007, Mia,     t=1
0042, Omar,    t=2
0042, Omar,    t=5   (re-registration, different email)
0117, Petra K., t=3
0203, Quan,    t=4
0450, Tara,    t=6

Your deliverables:

  1. A one-line normalisation rule that makes ids comparable across the two exports.
  2. A dedup rule: which field is the key, and which row wins when a key appears more than once?
  3. The final unique-student count, the id of every duplicate you removed, and every row you flag rather than merge (with the reason).
  4. One ambiguity in this data that you would escalate to a human instead of deciding yourself.

If the problem is ambiguous anywhere, state the assumption you are making and carry on — a stated assumption is part of a good answer.

Examples

Solve for the worked instance first. Then ask what would change if one number, name, or condition were replaced by something stranger.

What to notice

Discussion starter

After the solution is revealed, the class spends five minutes on this prompt: "Next month a third export arrives with no ids at all — name and programme only. Which of your rules survives, and which must be redesigned?"

Constraints and assumptions

Hints and extension