Skills / Data analysis / Cleaning data: the work nobody sees
Data analysis, lesson 2 of 8
Cleaning data: the work nobody sees
Real data is messy. Analysts often say most of their time goes into cleaning, and it is worth it: every problem you miss flows straight into your conclusions.
The usual suspects:
- Duplicates: the same order recorded twice inflates every total. Decide what makes a row unique (an order number, say) and remove repeats.
- Inconsistent text: "Mumbai", "mumbai", "Bombay" and "Mumbai " (with a trailing space) are four different values to a computer. Trim spaces, fix capitals, and map variants to one standard name.
- Missing values: blank cells. Find out *why* they are missing before deciding what to do. You can leave them out, fill them with a sensible value, or flag them, but never silently treat a blank as zero.
- Wrong types: numbers stored as text, or dates in mixed formats (is 03/04/2026 the 3rd of April or the 4th of March?). Convert to proper numbers and dates.
- Impossible values: an age of 240, a negative quantity, a delivery date before the order date. Investigate each; some are typing errors, some are real refunds.
- Outliers: values far from the rest. They may be errors or the most interesting rows in the data. Check before you remove anything.
Work safely:
- Never edit the original file. Keep it untouched and clean a copy.
- Write down every change you make, so the work can be repeated and checked.
- Count rows before and after each step, so nothing disappears unexpectedly.
In spreadsheets, functions like TRIM, PROPER and Remove duplicates help. In Python, the pandas library does the same at scale.
Try it: List every data quality problem you can find in this set of city names: "Delhi", "delhi", "New Delhi", "Delhi " (trailing space), "", "DELHI". Then decide what you would do with each one.
The tutor gives hints, not finished answers. Log in to use it.