How do you detect and handle missing values in Pandas with dropping, filling, forward/backward fill and interpolation?
Role: Data Scientist
Category: Data Manipulation (SQL/Python)
Difficulty: easy
Interview Round: Other
How do you detect missing values and handle them through dropping, filling, forward/backward fill, and interpolation in Pandas? For each approach, say when you would choose it.
```hint Ask why the values are missing
Before picking a method, consider whether the rows have a natural order such as time, and whether the reason a value is missing could depend on the value itself.
```
### What a Strong Answer Covers
- How to find and count missing values, including missing markers that pandas does not recognize by default
- When dropping rows or columns is acceptable, and the options that control it
- Filling with constants or statistics, and computing those statistics without leaking information
- Forward fill, backward fill and interpolation, including sorting, grouping and irregular spacing
- Common pitfalls such as unassigned results and dtype changes
### Follow-up Questions
- How would you fill missing prices with the median of each store instead of the global median?
- Why can backward fill or interpolation leak information into a forecasting model?
- When would you add a "was missing" indicator column next to the filled value?
- How does `interpolate()` behave at the start and end of a series, and how do you change that?
Overview: Asks how to find missing values in a pandas DataFrame and when to drop rows, fill with constants or statistics, forward or backward fill, or interpolate. It tests practical data cleaning judgment, including ordering, grouping, leakage and common pandas pitfalls.