Try it: build a series
Move the sliders. The pink line is your series. It is made of the three parts below it.
Your seriesTrend alone
Three parts hide inside almost every series
Trend is the slow direction. A cafe that gets more popular has sales that climb over the year.
Seasonality is a pattern that repeats on a fixed calendar. Weekends are busy, December is busy, summer is slow. The gap between repeats is called the period: 7 for days of a week, 12 for months of a year.
Noise is everything else: the rainy Tuesday, the one-off event, plain luck. You cannot forecast noise. You can only describe how big it usually is.
Make your own series
Run this once. It builds a year of made-up cafe sales with a growing trend, busy weekends and some noise. We reuse it in every lesson.
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
rng = np.random.default_rng(42)
days = pd.date_range("2024-01-01", periods=365, freq="D")
trend = np.linspace(100, 140, 365) # sales slowly grow
week = np.array([-8, -6, -4, 0, 6, 16, 12])[days.dayofweek] # busy weekends
s = pd.Series(trend + week + rng.normal(0, 4, 365), index=days, name="sales")
s.plot(figsize=(9, 3), title="Daily cafe sales")
plt.show()Time series are different from normal tables
In a normal table you can shuffle the rows and nothing changes. In a time series, shuffling destroys the story. Two rules follow from this and we use them all course long: always keep the order, and never let the model see the future.