Data Cleaning Exercises

Task: the rules
Input
  transactions(id, type, amount) — text. id is unique. type is sale or refund.
  amount is always valid: optional "-", digits, optionally "." and 1–2 digits. Refunds are negative.

Rules
  amount: convert to an exact decimal with 2 places (12.5 means 12.50).
  needs_review: true when amount is greater than 5000.00, otherwise false.
  Keep every row. Large values are flagged, never removed or capped.

Output (row order does not matter)
  clean(id text, type text, amount decimal(12,2), needs_review bool)

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

Input: transactions, rows 1 to 9 of 9
#idstringtypestringamountstring
1twnh2sale128.99
2tthzjsale3529
3tkv8bsale8988.5
4two43sale280.05
5tgsijsale11052.01
6t958jrefund-3290.10
7tbd8esale2294.10
8tu51rsale1710.05
9thfhmsale5000.00

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