How do forward-fill, backward-fill, and interpolation differ for filling gaps, and what are the risks of each?
Quick Overview
Compares forward-fill, backward-fill and interpolation as ways to fill missing values in ordered or time series data. Tests whether you know which values each method reads, which signals each one suits, and how staleness, invented trends and lookahead leakage can creep into a model.
How do forward-fill, backward-fill, and interpolation differ for filling gaps, and what are the risks of each?
Role: Data Scientist
Category: Data Manipulation (SQL/Python)
Difficulty: medium
Interview Round: Other
How do forward-fill, backward-fill, and interpolation differ as approaches to filling gaps, and what are the risks of each?
Assume ordered data with some missing values, such as a daily sensor series or a table of account balances over time.
```hint Which values each method reads
For each method, ask which known observations it uses to fill a missing point: earlier ones, later ones, or both. Then think about what that means if the filled data feeds a forecast.
```
### What a Strong Answer Covers
- How each method picks a fill value, and which kinds of signals each one suits
- Which methods use information from after the gap, and why that matters for forecasting and model training
- What goes wrong over long gaps, and how to cap the fill distance
- Practical preconditions: sorting by the time index and filling within each entity
### Follow-up Questions
- You are building features for a next-day demand forecast. Which fills are safe to apply, and at what point in the pipeline?
- How would you fill gaps in a panel dataset where each customer has their own time series?
- When would you leave a value missing and add a missing-indicator feature instead of filling it?
- How does time-weighted interpolation differ from interpolation by row position when timestamps are irregular?
Overview: Compares forward-fill, backward-fill and interpolation as ways to fill missing values in ordered or time series data. Tests whether you know which values each method reads, which signals each one suits, and how staleness, invented trends and lookahead leakage can creep into a model.