


PYTHON APPLIED
Loading and cleaning messy data
Real-world data is messy. Columns may have missing values (NaN), incorrect types, or inconsistent formatting. Pandas provides tools to detect, fill, drop, and convert bad data before analysis.
How it reads
pd.to_numeric(..., errors='coerce') converts invalid strings to NaN
.fillna(median) replaces missing values with the column's median
.dropna(subset=['city']) removes rows where city is missing

Cloud tip: Always inspect your data with df.info() and df.isna().sum() before analysis to understand the scope of missing or mistyped values.
Check your understanding
Answer all 3 to complete this lesson · +15 XP
1. What does NaN represent in a Pandas DataFrame?
2. Which method removes rows that have missing values in specific columns?
3. What does pd.to_numeric(series, errors='coerce') do with non-numeric strings?
