0Pricing
Data Science Academy · Lesson

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

  1. Find the NaNs Hiding in Your Table
  2. Drop vs Fill: Choosing Wisely
  3. Impute With Mean, Median, or Mode
  4. Fix dtypes and Duplicate Rows
← Back to Data Science Academy