Time Series • Introduction to Time Series
Time Series / P1.01 Chronological Time Series Data

P1.01 Chronological Time Series Data

Practical 1 Introduction to Time Series

A shop recorded weekly packet sales for eight weeks. Arrange the values as a time series, keep chronological order, and explain why the order must not be shuffled.

Practical / Solution

P1.01 Chronological Time Series Data

Problem Statement

A shop recorded weekly packet sales for eight weeks. Arrange the values as a time series, keep chronological order, and explain why the order must not be shuffled.

Learning Outcomes

  • Define a time series using a small dataset.
  • Store observations with a proper time index.
  • Explain why chronological order is essential.

Hint

Create a date index first, then attach the sales values. Do not sort the values by size.

Theory

A time series is a sequence of observations recorded over time. The time order is part of the information. If the order is changed, trend and seasonality can no longer be studied.

Dataset / Data Source

Small teaching dataset: weekly packet sales for eight consecutive weeks starting 6 Jan 2026: 42, 45, 44, 50, 53, 49, 55, 58. This is a constructed classroom series, not a downloaded public file.

Analysis / Program

# Import libraries import pandas as pd import matplotlib.pyplot as plt # Create a chronological weekly index weeks = pd.date_range("2026-01-06", periods=8, freq="W-MON") sales = [42, 45, 44, 50, 53, 49, 55, 58] # Load data into a time series ts = pd.Series(sales, index=weeks, name="packet_sales") # Inspect the series print(ts) print("Chronological order preserved:", ts.index.is_monotonic_increasing) # Plot the series in time order ts.plot(marker="o", title="Weekly packet sales") plt.xlabel("Week") plt.ylabel("Packets sold") plt.tight_layout() plt.show()

Expected Output

A table of eight dated observations, True for chronological order, and a rising line chart. Exact pixels of the chart depend on your machine; the shape should show a general increase with one small dip in week 6.

Result / Interpretation

The series is a valid time series because each value is tied to a week. The later weeks are higher than the first weeks, so a simple upward movement is visible. Shuffling the eight numbers would destroy that movement.

Note

Time-series analysis starts by preserving time order. Sorting values from smallest to largest is not time series analysis.