Data cleaning & preparation
Real-world data is messy. Data cleaning means finding and fixing problems before the data is used. It's not glamorous, but data teams often spend most of their time on it, because a model trained on messy data gives messy answers.
Everyday analogy
Washing, peeling and sorting vegetables before cooking. Skip it and the whole dish suffers, however good the recipe.
Example
A customer list has "Bangalore", "Bengaluru" and "BLR" as three different cities. Until they're merged, any analysis will think they are three separate places.
Before cleaning
| Name | City | Age | Joined | Problem |
|---|---|---|---|---|
| Asha Rao | Bangalore | 34 | 12/03/2024 | City spelt three ways |
| asha rao | Bengaluru | 34 | 2024-03-12 | Duplicate person, mixed date formats |
| Vikram | BLR | 250 | 2024-05-01 | Impossible age (outlier) |
| Neha | Mumbai | 2024-06-20 | Missing age |
After cleaning
| Name | City | Age | Joined |
|---|---|---|---|
| Asha Rao | Bengaluru | 34 | 2024-03-12 |
| Vikram | Bengaluru | 25 (confirmed typo) | 2024-05-01 |
| Neha | Mumbai | unknown (flagged) | 2024-06-20 |
Try it yourself
About 20 minClean a messy table
- In a spreadsheet, type 10 rows of customer data with mistakes: duplicates, 'Delhi' and 'delhi', blank ages, an age of 250.
- Fix them using sort, find-and-replace and filters.
- Write the rules you used.
What you should see: Data cleaning is the unglamorous step that makes AI work.
Use any free AI chatbot (ChatGPT, Claude, Gemini or Copilot). Never paste private or confidential information.