Data Science and Data Scientist

Module 36 of 43

Module 36: Time Series

5 min read801 words
What you'll learn
Explain what time series data isRecognize trend and seasonalityUnderstand basic forecasting

"When data is ordered in time — prices, weather, sales — you can study its rhythm and forecast what comes next."

Learning Objectives

By the end of this module, you will be able to:

  • Explain what time series data is
  • Recognize trend and seasonality
  • Understand basic forecasting

1. Data in Time Order

A time series is data points recorded in order over time — daily sales, hourly temperature, monthly users. The order is essential and can't be shuffled.

Key idea: Unlike other data, time series can't be jumbled — Tuesday follows Monday, and last month influences this month. That ordering is exactly the pattern you're trying to learn.

Explain like I'm new: In most datasets, each row is independent — shuffling a table of customers doesn't lose any information. Time series is different: the sequence is the information. Shuffling the days of a stock price would be like shuffling the pages of a book — you'd keep every word but destroy the story.

You meet time series everywhere: your step count by day, a website's visitors by hour, a country's rainfall by month, a company's revenue by quarter. What unites them is that each value is connected to the ones before it, and often the same value tomorrow depends heavily on today.

2. Trend & Seasonality

Most time series mix two patterns:

  • Trend — the long-term direction (steady growth over years)
  • Seasonality — repeating cycles (busy every weekend, sales spike each December)

Simple example: Ice-cream sales show an upward summer trend plus a weekly seasonal bump on weekends. Spotting both is the key to forecasting them.

Think of the two patterns as layers stacked on top of each other. The trend is the slow escalator — where things are heading over months or years. Seasonality is the regular wave riding on top — the predictable ups and downs that repeat on a fixed schedule (daily, weekly, yearly). Real data usually has both, plus a bit of random noise sprinkled on top. Separating these layers is called decomposition, and it's often the first analytical move.

Try this: Look at a retailer's monthly sales for two years. You'll likely spot a gentle upward trend and a giant seasonal spike every December for the holidays. Naming those two patterns out loud is already half of understanding the data.

3. Forecasting

Forecasting predicts future values from past patterns. Classic methods like ARIMA use recent values and past errors to project ahead.

The intuition behind most forecasting is simple: the near future usually resembles the recent past, adjusted for the trend and the current point in the seasonal cycle. If it's early December and sales have been climbing all year, a good forecast expects both the holiday spike and the upward trend. Fancier methods just capture these relationships more precisely.

The gentlest forecasting tool is the moving average — smoothing the line by averaging each point with its neighbors. It cuts through the day-to-day noise so the underlying trend stands out, and it's often the first thing you'll plot. A "7-day moving average," for instance, replaces each day with the average of that week, turning a jagged daily line into a smooth curve you can actually read.

Explain like I'm new: Forecasting isn't fortune-telling. A forecast is a best estimate with a range of uncertainty, not a guarantee. Good forecasts come with error bars — "next week's sales will likely be 900 to 1,100" — because the future always holds surprises the past can't fully predict. Treat any single-number forecast with healthy suspicion.

Real-world use case: A coffee chain forecasts next week's demand per store so each location orders the right amount of beans and milk. Under-forecast and shelves go empty; over-forecast and product spoils. A model that captures the weekday rhythm plus the slow growth trend saves real money on both sides.

Common mistake: Splitting time-series data randomly into train/test (Module 30). You must train on earlier data and test on later — otherwise the model "sees the future," and your results are fiction.

Data scientist tip: Always plot a time series first. Trend, seasonality, gaps, and odd spikes jump out visually — and that picture guides every modeling choice you'll make.

Key Takeaway: A time series is time-ordered data whose sequence carries meaning (never shuffle it). It combines trend (long-term direction) and seasonality (repeating cycles), plus noise — separating those layers is decomposition. Forecasting (e.g., ARIMA) projects future values — and you must train on earlier data, test on later. Always plot it first.

Further Learning

Part of the "Data Science and Data Scientist" course.