Time Series • Introduction to Time Series
Time Series / P1.05 Nature of a Time Series Dataset

P1.05 Nature of a Time Series Dataset

Practical 1 Introduction to Time Series

Inspect a monthly electricity-demand-like series: frequency, length, missing values and whether it looks suitable for forecasting.

Practical / Solution

P1.05 Nature of a Time Series Dataset

Problem Statement

Inspect a monthly electricity-demand-like series: frequency, length, missing values and whether it looks suitable for forecasting.

Learning Outcomes

  • Report frequency and sample length.
  • Check missing values.
  • Comment on whether the history is long enough for a simple forecast.

Hint

Print dtype, index frequency, missing count and a short head/tail.

Theory

Forecast quality depends on suitable data: relevant variable, regular frequency, adequate length and acceptable quality.

Dataset / Data Source

Constructed 18 monthly demand values with one missing month. Teaching data only.

Analysis / Program

import pandas as pd import numpy as np idx = pd.date_range("2024-07-01", periods=18, freq="MS") demand = [120, 118, 125, 130, 128, 140, 155, 160, 150, 142, 138, 135, 133, np.nan, 141, 148, 152, 158] ts = pd.Series(demand, index=idx, name="demand") print("Length:", len(ts)) print("Inferred frequency:", pd.infer_freq(ts.index)) print("Missing values:", ts.isna().sum()) print(ts.head()) print(ts.tail())

Expected Output

Length 18, monthly frequency, one missing value, and printed first and last observations.

Result / Interpretation

The series is monthly and fairly short. One missing month must be handled before forecasting. Eighteen points can support a simple method, but not a heavy seasonal ARIMA study.

Note

A forecast is only as useful as the data behind it. Missing values and short history are Unit 1 issues, not later-model issues.