Data Cleaning Exercises

Module 6

Numbers and money

Locale-aware parsing, exact decimals, units, separate currencies and explicit rounding.
  1. Exact decimals for money

    Parse amounts into exact decimals, reject text that would need rounding, and compare thresholds precisely. · 8 min

  2. Negative amounts in accounting notation

    Parse negatives written with a minus sign, parentheses or a trailing minus, only as the rules allow. · 7 min

  3. Totals per currency

    Aggregate amounts per currency and never add different currencies together. · 6 min

  4. Rounding on purpose

    Round only where a rule says so, with a declared mode, and never silently during casting. · 6 min

Module 6 quiz

Practice questions: choose an answer and check it to see the explanation. Nothing here is timed or graded.

  1. 1. In Python, what is 0.1 + 0.2 == 0.3?
  2. 2. An amount column mixes USD and EUR. The report wants one total. What should you deliver?
  3. 3. Under en-US conventions, what number is "1,234.50"? And under de-DE, what is "1.234,50"?
  4. 4. Rounding 2.675 to 2 decimals with round-half-even on an exact decimal gives?
  5. 5. Why store money as integer cents or a DECIMAL type?
  6. 6. An amount is written "(125.00)". The rules say parentheses mean negative. What is the value?