Time Series • Time Series Analysis and Components
Time Series / P2.08 Unusual Observations

P2.08 Unusual Observations

Practical 2 Time Series Analysis and Components

Detect an unusual month in a demand series and discuss whether to adjust it before a simple forecast.

Practical / Solution

P2.08 Unusual Observations

Problem Statement

Detect an unusual month in a demand series and discuss whether to adjust it before a simple forecast.

Learning Outcomes

  • Flag an observation that breaks the local pattern.
  • State a transparent adjustment option.

Theory

Unusual observations may be errors or genuine shocks. Adjustment is a judgement: replacing a known strike month by a neighbour can help a short-term forecast, but it must be documented.

Dataset / Data Source

Monthly demand 40, 42, 41, 43, 12, 45, 46. The 12 is a simulated disruption.

Analysis / Program

import pandas as pd idx = pd.date_range("2025-01-01", periods=7, freq="MS") y = pd.Series([40, 42, 41, 43, 12, 45, 46], index=idx) median = y.median() flag = y[y < median - 10] print("Flagged:", flag) adjusted = y.copy() adjusted.loc[flag.index] = y.drop(flag.index).mean() print(pd.DataFrame({"original": y, "adjusted": adjusted.round(1)}))

Expected Output

The month with 12 is flagged. The adjusted table replaces it by the mean of the other months.

Result / Interpretation

If the 12 was a one-off closure, adjustment may be reasonable for studying the usual level. If it can happen again, the shock is part of the risk and should not be hidden.

Note

Never silently delete a shock. Record why an adjustment was made.