~/learn/Pandas · Cleaning data
Missing data and cleaning
Handle NaN, types and duplicates before you analyse.
7 min readlesson 7 of 13nanfillnaduplicates
why this matters
Analysts often say 80% of the job is cleaning. Missing values and duplicates will skew every number you report.
Missing values show up as NaN. isna() flags them, dropna() removes rows and fillna() replaces them.
python · editable
loading editor…
Fix types explicitly with astype or the to_ helpers, and remove exact repeats with drop_duplicates.
python · editable
loading editor…
Note
Chain your cleaning steps and reassign the result — most pandas methods return a new frame rather than editing in place.
key takeaways
- isna().sum() counts missing values per column.
- fillna fills gaps; dropna removes them.
- drop_duplicates removes repeated rows.
check your understanding
How do you count missing values in each column?
free practice
Build confidence with a question you can solve without Pro.