Impute With Mean, Median, or Mode
Sensible fills per column type.
Filling With a Statistic
Instead of inventing random numbers, you fill gaps with a summary value from the column itself. This careful approach is called imputation. 🧮
The Mean Fill
For numbers, the simplest choice is the mean, the column average. It keeps the overall total roughly intact when gaps are few.
df['age'].fillna(df['age'].mean())All lessons in this course
- Find the NaNs Hiding in Your Table
- Drop vs Fill: Choosing Wisely
- Impute With Mean, Median, or Mode
- Fix dtypes and Duplicate Rows