How do I clean messy data before analysing it?
Data cleaning means fixing or removing problems in a dataset so that your results are reliable. Real data often has missing values, duplicates, inconsistent formats and obvious entry errors.
A basic routine: 1) Keep a copy of the original data and work on a copy. 2) Look at the data first: column names, types, ranges and a few rows. 3) Remove exact duplicates. 4) Handle missing values deliberately: fill, estimate or remove them, and note what you chose. 5) Make formats consistent, such as dates, units and spelling of categories. 6) Check for impossible values, for example an age of 250.
Write down every change you make. This lets someone repeat your work and helps you explain your results.
What is the messiest dataset you have seen?