Clean the mess
Real data has blanks, typos and impossible values. Find them, decide what to do, and see how much the answer changes.
Data scientists joke that 80% of the job is cleaning. A single typo can wreck an average, so cleaning comes before any conclusion.
Spot the problems
Turn the model and find the yellow balls:
- Student 24 scored 999. The test is out of 100, so this is a typo, perhaps for 99.
- Student 32 studied −3 hours. Impossible.
- Students 6, 18 and 37 have a blank: a score, an hours value or a sleep value is missing.
Press Remove the broken rows and watch the mean score: it drops from over 75 to about 53. One typo had dragged it up by more than 20 marks.
Check every value with code
What to do with a broken row
| choice | when it makes sense |
|---|---|
| remove the row | few broken rows, no pattern in which ones |
| fix it | you can check the original, such as the marked paper |
| fill the gap | many gaps; fill with the median, and say so |
Whatever you choose, write it down. Anyone checking your work should be able to repeat it.
What to remember
- Look for blanks, typos and values that cannot be true.
- One bad value can move an average a long way.
- Remove, fix or fill broken rows, and record what you did.
- Check rules in code, such as "a score is between 0 and 100".