1. A cleaning routine you can reuse
Real datasets are rarely ready to analyse, and preparing them often takes longer than the analysis itself. Work through the same checks every time: duplicates, inconsistent text, missing values and data types.
- Duplicates:
drop_duplicates()removes the second copy of student 204. - Text: stripping spaces and using title case turns " python" and "Python" into one category.
- Missing values: the gap in student 202's score is filled with the median.
- Dates:
pd.to_datetimeturns both date styles into proper dates.dayfirst=Truereads 02/04/2026 as 2 April, the UK and Australian convention.
2. Why the median?
The median isn't pulled around by one unusually high or low score, so it's the safer choice when the data might be skewed. If the scores are roughly symmetrical, the mean gives a similar result.
3. A note on newer Pandas
Assign the result back (df["score"] = df["score"].fillna(...)) rather than calling fillna(..., inplace=True) on a single column. Recent Pandas versions warn about the in-place form on a column, and it can silently do nothing.