Time Series

Time series is data recorded in order, at intervals, over time. It might be numeric — financial data, energy load, stock prices — or categorical, like demographic snapshots or weather conditions. What unites time series data is that the order matters. You can't shuffle the rows the way you could in a survey.

Sample Rate: The Most Important Decision You'll Make

How often was the data collected? Hourly? Daily? Monthly? Every five minutes? Sample rate decisions are not technical decisions — they're modeling decisions.

  • Do you really need to record weather every minute? Probably not.
  • Do you want a heart-rate reading every week? Probably not.
  • The right sample rate is driven by the patterns you're trying to capture. What temporal resolution do those patterns require? Faster than that is wasteful. Slower and the patterns disappear from your data entirely.

Connection to Feature Engineering

You'll see time series again in Chapter 7 when we talk about engineering features for it — rolling statistics, lag features, seasonal decompositions. For now, just internalize: sequential data, sample rate matters, granularity is a modeling choice.

Time Domain vs. Frequency Domain

The same signal, two ways of looking at it. Toggle frequency components on and off to see how they combine in the time domain — and how the frequency domain strips that complexity back to a clean list of what frequencies are present and how strong they are.

Signal components — click to toggle

Time Domain

amplitude over time

0s0.5s1s1.5s2s

The green composite is what you would actually record with a sensor — all frequencies mixed together, inseparable by eye. Hover a toggle to see that component as a faint dashed line.

Frequency Domain

amplitude at each frequency

70%1 Hz45%3 Hz28%7 Hz18%12 Hz

The frequency domain reveals exactly which frequencies are present and at what strength — something impossible to read from the time-domain waveform. This is what a Fourier transform gives you: a decomposition of any signal into its constituent frequencies.

Why this matters for sensor data

  • Time domain — tells you when something happened: a spike, a trend, a burst of activity.
  • Frequency domain — tells you what rhythms drive the signal: breathing rate, vibration modes, electrical noise at 50/60 Hz.
  • Feature engineering often requires both: time-domain statistics (mean, variance, peaks) for event detection; frequency-domain features (spectral power bands) for rhythm-based classification.

Toggle frequency components to see how they combine in the time domain — and how the frequency domain makes each component visible separately.

High-Frequency Trading vs. Macroeconomics

High-frequency trading firms sample on sub-millisecond cadences because their patterns live there. Macroeconomic forecasters sample monthly or quarterly because their patterns live there. Both are right — they're working on different problems. The sample rate follows from the application, not from convention.

Checkpoint

Why can't you shuffle the rows of a time series dataset the way you can shuffle rows of a survey?