Data Cleaning Exercises

Task: the rules
Input
  records(id, account, updated, priority) — all text. id is unique. account keeps its leading zeros.
  updated is an ISO 8601 timestamp with an explicit offset; priority is a whole number. Both are always present and valid.

Rule
  Keep one row per account. The survivor is the row with:
    1. the latest updated instant (compare instants, not text: 01:00+01:00 equals 00:00Z),
    2. then the higher priority,
    3. then the lowest id (code-point order).
  Every other row goes to exceptions with reason "duplicate".

Outputs (row order does not matter)
  clean(id text, account text, updated timestamptz [UTC], priority int64)
  exceptions(id text, reason text)

Tab inserts spaces. Press Escape, then Tab, to move focus out of the editor.

Input: records, rows 1 to 13 of 13
#idstringaccountstringupdatedstringprioritystring
1rllcz0000642026-03-10T23:15:00Z9
2rsilp0004582026-03-11T00:15:00+01:0010
3r35yg0000642026-02-01T00:00:00Z3
4rwy4c0008752026-03-10T23:15:00Z1
5reqt90000642026-01-15T08:00:00Z9
6r3mue0007482026-02-01T12:30:00Z2
7rsiq70004582026-02-01T00:00:00Z12
8rfk2c0004582026-03-11T00:15:00+01:0012
9rxvfh0004582026-02-01T12:30:00Z9
10r06sr0009412026-02-01T00:00:00Z1
11r4gch0007482026-01-15T08:00:00Z2
12r8klo0000642026-03-10T23:15:00Z1
13r3qhx0008752026-02-01T00:00:00Z12

Run preview · in your browser, not a grade

Loading the preview runtime…

Check answer · graded on an isolated server, including hidden datasets

Your code runs in a locked-down machine with no network, on the visible data and on hidden datasets that follow the same rules.

Learn from this exercise

A worked solution becomes available after your first check or once you've used every hint.

AI tutor · may be wrong; the grader decides

Python · Python 3.14 · pandas 3.0.2Preview runtime loadingNot saved yet · sign in to save to your account