Home › Interview Questions › What methods would you use to fill null values in …

What methods would you use to fill null values in the salary column?

🟡 Medium Conceptual Junior level
1Times asked
Sep 2026Last seen
Sep 2026First seen

💡 Model Answer

To handle null values in a salary column, I would first analyze the distribution and missingness pattern. If the missingness is random, a simple imputation such as the mean or median is often sufficient. For skewed salary data, median is preferable. If domain knowledge suggests a specific value, a constant (e.g., 0 or a typical entry‑level salary) can be used. For more sophisticated approaches, I might use predictive modeling: train a regression model (linear regression, random forest, XGBoost) on the other columns to predict the missing salary. In Pandas, this can be done with df['salary'].fillna(df['salary'].median(), inplace=True) or using sklearn's SimpleImputer. The choice depends on the business context, the proportion of missing data, and the impact on downstream analytics. Complexity is O(n) for simple fill, and higher for model‑based imputation.

This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.

🎤 Get questions like this answered in real-time

Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers on a discreet on-screen overlay.

Get Assisting AI — Starts at ₹500