/knowledge/notes/filling-gaps-in-time-series
Concept note · ML
Filling Gaps in Time Series
Time Series
- Studied
- Time SeriesMAST90083
- When
- 2024 S1
- Applied in
- SA Gaming Machine Statistics
- Read / Refreshed
- ~5 min read2026-10-15
Time series data often has gaps: a sensor fails, a survey is skipped, or a fiscal year's report is missing. Three methods—forward fill, backward fill, and interpolation—each make different assumptions about how the missing value relates to its neighbours. The choice matters for prediction and causal inference.
01
The idea
Forward fill (ffill) copies the last known value forward. It assumes the variable stays constant until new data arrives. Backward fill (bfill) copies the next value backward. It assumes the future value existed earlier, which leaks future information into the past and breaks temporal causality. Interpolation—linear, spline, or polynomial—fits a curve between neighbours. It assumes smooth transitions.
For prediction tasks, forward fill is safe: the model sees only past values. Backward fill is not safe: it uses future values the model would not have at prediction time. Interpolation is safe if it uses only past neighbours, dangerous if it uses future ones.
02
The maths
03
Try it
04
Where I used it
05
Easy to get wrong
06
Sources
MAST90083 Time Series (2024). Missing data strategies for forecast models.