How would you handle 10% null values in a key column?
This tests your understanding of data cleaning trade-offs. First, investigate the cause of nulls. Then, discuss simple imputation (mean/median) vs. discarding rows, weighing pros and cons. A red flag is jumping to a solution without asking about the data.
WHAT THIS TESTS: This question tests your practical data handling skills, not just theoretical knowledge. The interviewer wants to see if you think about the implications of your choices. Do you investigate first, or just apply a formula? Can you articulate the trade-offs between simple methods like dropping data vs. imputing it with a mean or median? At 10% missing data, your choice has a real impact on the final dashboard.
A GOOD ANSWER COVERS: A strong answer has a clear, ordered structure. First, state the need to investigate the cause of the nulls—are they random, or is there a pattern (e.g., all from one specific device)? Second, explicitly state that dropping 10% of the data is usually too high a price to pay and should be avoided. Third, propose univariate imputation as a good starting point. Discuss the main strategies: using the mean (good for normally distributed data), the median (better for skewed data with outliers), or a constant value (e.g., 0, if that makes sense in the context). Fourth, explain the pros and cons of the chosen method, such as how using the mean can reduce variance and pull the distribution towards the center.
COMMON WRONG ANSWERS: A major red flag is jumping to a solution without asking questions. For example, "I'd just replace them with the mean." This shows a lack of critical thinking about the data's distribution. Another weak answer is suggesting to drop all rows with nulls. Losing 10% of your data is significant and this approach ignores the potential value in the incomplete rows. Suggesting overly complex multivariate imputation (e.g., using scikit-learn's IterativeImputer) without first justifying why simple methods are insufficient is also a sign of inexperience. Start simple.
LIKELY FOLLOW-UPS: "How would your answer change if 50% of the data was null?" (At this point, imputation is very risky and the data source's integrity is questionable; the column might need to be dropped). "What if the column wasn't numerical, but categorical?" (Impute with the mode/most frequent value, or a new category like 'Unknown'). "How would you implement this in Python?" (Mention pandas.fillna() or scikit-learn's SimpleImputer).
ONE CONCRETE EXAMPLE: Imagine a 'user_age' column where 10% of values are null. The age distribution is skewed right by a few very high values. Dropping the rows is not ideal as we'd lose 10% of our users. Using the mean age (e.g., 45) would be biased upwards by the outliers. A better choice is to impute with the median age (e.g., 35), as it's more robust to outliers and better represents the central tendency of the skewed data. You could implement this with df['user_age'].fillna(df['user_age'].median(), inplace=True).
Read the original → scikit-learn.org
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.