A monthly series has a missing value and mixed types. Clean it into a regular datetime-indexed series ready for forecasting.
A monthly series has a missing value and mixed types. Clean it into a regular datetime-indexed series ready for forecasting.
Convert to datetime, set_index, asfreq('MS'), then interpolate or use a clearly stated fill method.
Preparation includes consistent frequency, numeric type, and a documented missing-value rule. Silent filling without comment is poor practice.
Teaching CSV-like rows: 2025-01, 20; 2025-02, 22; 2025-03, missing; 2025-04, 25; 2025-05, 24.
A five-month series with NaN in March, then a filled March value between February and April.
The cleaned series is regular and numeric. Interpolation is acceptable here because only one interior point is missing. Students must record the rule they used.
Never start modelling on a series whose missing values have not been inspected.