Skip to content

Data Cleaning

Data Types & Parsing

7 min+65 XPStep 1/10

Everything arrives as a string

Raw data has no types — only text that looks typed. One CSV column shows 2024-03-01 for US rows, 01/03/2024 for UK rows, and March 1 in manual entries. One column, three formats, plus a March-vs-January ambiguity on top.

Every column needs a type decision: number, date, category, or free text. The parser is where cleaning actually happens — and where subtle errors get baked in silently.

Common casualties:

  • Dates: is 01/03/2024 March 1 or January 3? Parse it wrong once and every analysis inherits the error
  • Numbers: $1,234.56 won't parse until you strip the currency symbol and the comma
  • IDs: leading zeros matter — ZIP 02134 parsed as a number becomes 2134

warning

A silent parse failure — a date that becomes `null`, a price stored as text — never raises an error. It just quietly poisons every downstream number.