Imputation

fillna() replaces missing values with a fixed or computed value: a constant, the mean, the median or the most frequent value. This imputation keeps the rows but changes the distribution. The median is more robust than the mean in the presence of extreme values.

Example

df['age'] = df['age'].fillna(df['age'].median())

Related concepts

The whole glossary