What Data Cleaning Is and Why It Matters
See how duplicate rows and mixed units can fake a 40% revenue jump, learn the six data quality dimensions, and meet a five-step cleaning workflow.
Welcome back!
Step 1 of 11Learn
The 40% jump that never happened
On a Monday morning, the sales dashboard at a small online retailer showed revenue up 40% over the previous month. The team celebrated for about an hour. Then an analyst noticed that the number of orders had grown much faster than the number of customers.
Two problems were hiding in the data. First, a migration to a new order system had re-exported three weeks of old orders, so about 2,000 orders appeared twice. Second, one payment provider reported amounts in cents while everything else used dollars, so a $25 order from that provider looked like a $2,500 order. Real growth that month was about 3%.
Nobody made a dramatic mistake. Each system did exactly what it was told. The errors came from the seams between systems, which is where most dirty data is born: exports, merges, manual entry, changing formats and software updates.
Data cleaning is the work of finding and fixing these problems so that the numbers describe reality. It sounds like janitorial work, but it decides whether every chart, model and decision built on top of it can be trusted. In this course you will learn a repeatable process for doing it well, with Python examples you can run in the browser.
Step 2 of 11Learn
Six dimensions of data quality
"Clean" is vague, so analysts break data quality into dimensions you can check one at a time:
- Accuracy: values match the real world. A customer's recorded age of 212 is inaccurate.
- Completeness: required values are present. A shipping table where 30% of rows lack a postal code is incomplete.
- Consistency: the same fact is recorded the same way everywhere. "NY", "New York" and "new york " in one column are inconsistent.
- Validity: values follow the rules of their type and domain. An email without an @ sign, or a date of February 30, is invalid.
- Uniqueness: each real-world entity appears once. The duplicated orders in the retailer story break uniqueness.
- Timeliness: the data is current enough for its purpose. Last year's inventory counts are accurate history but useless for today's reorder decision.
A value can pass one check and fail another. "2025-02-30" has a perfectly consistent format but is invalid. A phone number can be valid in format but inaccurate because the customer moved. Naming the dimension tells you which kind of fix you need: a lookup, a rule, a deduplication step or a fresher source.
Step 3 of 11Practice · Match the pairs
Match each problem to the data quality dimension it violates.
Tap an answer, then tap the place where it belongs (or drag it there).
- A product appears twice in the catalog with different IDs
- A temperature sensor logs 900 °C in an office
- Half the survey rows have no answer for income
- Country is "UK" in one table and "United Kingdom" in another
- An order date is recorded as 2024-13-05
Step 4 of 11Learn
Tidy data: a target shape
Before fixing values, it helps to know what shape you are aiming for. A widely used standard is tidy data:
- Each variable is a column.
- Each observation is a row.
- Each value sits in its own cell.
Here is a common untidy table, with one column per year:
| store | 2023 | 2024 |
|---|---|---|
| North | 410 | 455 |
| South | 380 | 362 |
The year is a variable, but it is trapped in the column headers. The tidy version has three columns, store, year and sales, and four rows. That shape is easier to filter, group, plot and join, because every tool expects variables in columns.
Other untidy patterns include several values crammed into one cell ("red; blue; green"), two variables in one column ("M25-34" for sex and age group), and the same table split across many files or sheets. Tidy data is not the only valid layout, since a report for humans may be wider on purpose, but it is the best starting point for analysis. You will reshape tables between wide and long forms in the last module.
Step 5 of 11Practice · Choose one
Which column breaks the "each value in its own cell" rule of tidy data?
Step 6 of 11Tap to reveal
A five-step cleaning workflow
1. Profile
Look before you touch. Count rows, check types, count missing values per column, list distinct values and look at minimums and maximums. You are building a list of suspected problems.
2. Define rules
Write down what correct looks like: allowed values, valid ranges, required fields, which column identifies a row. Rules turn vague doubts into checks a script can run.
3. Fix
Apply changes in code: standardize formats, convert types, handle missing values, remove duplicates. Each fix should be a step you can rerun on fresh data.
4. Validate
Rerun the rules on the cleaned data and compare before and after counts. A fix that silently drops 8% of rows is a new problem, not a solution.
5. Document
Record what you changed and why in a cleaning log or in comments. Anyone who reads your results, including you in six months, needs to know that missing incomes were imputed with the median.
Step 7 of 11Practice · Put in order
Put the cleaning workflow steps in the order you should do them.
Drag the items, or use the arrow buttons, to put them in order.
- Define rules for what correct looks like
- Profile the raw data
- Apply fixes in a script
- Document what changed and why
- Validate the cleaned data against the rules
Step 8 of 11Note
Step 9 of 11Learn
Cleaning decisions are analysis decisions
It is tempting to think of cleaning as a neutral chore that happens before the real analysis. It isn't. Every cleaning choice can move your results.
Suppose a salary survey has 1,000 responses and 150 people skipped the income question. If you simply drop those 150 rows, and the people who skipped were mostly high earners who prefer privacy, your average income will be too low. If you fill the blanks with the overall mean, your average stays the same but the spread shrinks, so later tests become overconfident. Neither choice is automatically right; each has consequences you should know and report.
The same applies to outliers. Deleting a $9,800 order because it "looks weird" may remove your most important customer. Keeping a $980,000 order that was really a typo will wreck your averages.
Good analysts treat cleaning as part of the method. They make choices deliberately, test how sensitive the results are to those choices, and write them down. A useful habit is to ask, for each fix: if I had chosen differently, would my conclusion change? If yes, that choice deserves a sentence in the final report.
Step 10 of 11Practice · What would you do?
What would you do?
Your manager needs a customer count by region for a meeting in an hour. The export has obvious problems: region names are spelled several ways and some rows look duplicated. A colleague suggests opening the file in a spreadsheet, fixing the cells by hand and overwriting the original. What do you do?
Step 11 of 11Practice · True or false
If two analysts start from the same raw dataset, they will always reach the same results as long as they both clean the data carefully.
Lesson complete!