
Image by Author
What Is a Time Series?
A time series refers to a series of observations collected at a specific time interval and goes through to periods that are equally spaced.
In contrast to typical datasets, which maintain an arbitrary order, time series data has an ordered temporal dimension, which makes it a special case when analyzing data. Common examples may include stocks with daily prices or e-commerce sales.
Analyzing time series data is useful to identify the existing behavior in the data (for example, trends and seasonal behavior), and should be useful to forecast future values or identify outliers.
Key Characteristics of Time Series
Time series data are always defined by:
- Temporal ordering: Observations are ordered chronologically.
- Regular intervals: Data is collected at fixed time intervals (e.g., hourly, daily, monthly).
- Autocorrelation: Values at one point in time may be correlated with previous values.
The frequency of observation can vary from seconds, when analyzing sensor readings, to years, if we are working with census data, and this influences the modeling and visualization techniques applied.
- Time series analysis involves using statistical techniques to describe, understand, and model time-dependent data.
- Time series forecasting focuses on predicting future values based on historical trends and patterns.
The Four Pillars of Time Series Analysis
Time series data typically consists of four fundamental components. Decomposing a time series into these components can reveal its structure and guide appropriate modeling strategies.

1. Trend
The trend represents the long-term progression of the series. It indicates whether the values are generally increasing, decreasing, or remaining stable over time.
Its main characteristics:
- Reflects structural changes or growth over time
- Can be linear or nonlinear
- Often influenced by external factors such as population growth, inflation, or technological progress
2. Seasonality
Seasonality refers to repeating patterns or cycles that occur at regular intervals, typically within a year or less. These effects are driven by calendar-related phenomena such as weather, holidays, or business cycles.
Its main characteristics:
- Occurs at known, fixed frequencies (e.g., daily, weekly, monthly)
- Has consistent direction, magnitude, and timing
- May be additive or multiplicative, depending on how it interacts with the trend
3. Cyclical Components
The cyclical component represents fluctuations that occur over longer, variable periods, often influenced by economic, political, or environmental forces. Unlike seasonality, cycles do not follow a fixed calendar-based pattern.
Its main characteristics:
- Duration and amplitude are irregular
- Often observed in macroeconomic or financial data
- Influenced by external forces like business cycles, economic shocks, or policy changes
4. Irregular (Residual) Component
The irregular or residual component captures random, unpredictable variations that are not explained by trend, seasonality, or cycles. These fluctuations may result from unexpected events, measurement errors, or short-term disturbances.
Its main characteristics:
- Typically assumed to be white noise (zero mean, constant variance, no autocorrelation)
- Does not follow a pattern or structure
- May contain outliers or anomalies
Time Series Terminology
Some terminology that is always good to keep in mind when working with time series.
- Dependence: Time series data often shows autocorrelation, meaning current values are influenced by past observations of the same variable.
- Stationarity: A series is stationary if its statistical properties (mean, variance, autocorrelation) remain constant over time. Many models assume stationarity.
- Differencing: Used to transform non-stationary data into a stationary form by subtracting current values from previous ones. Over-differencing should be avoided.
- Model Specification: Involves selecting the right model (e.g., linear vs. non-linear) to capture the relationships in the data, such as with ARIMA.
- Exponential Smoothing: A forecasting method that gives more weight to recent observations. It’s effective for short-term predictions and noise reduction.
- Curve Fitting: Used when the data follows a non-linear trend. Curve fitting techniques model complex patterns beyond linear regression.
Time Series Analysis with Python
Now we will be working with the Airline Passangers dataset from Kaggle. In order to understand how to download the dataset and load it into our environment, you can go check my full code on my github repository or go check my previous article on KDnuggets about time series with pandas.
So once the dataset is loaded, the next step is to visualize the time series.
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
def plot_df(df, x, y, title="", xlabel='Date', ylabel='Number of Passengers', dpi=100):
plt.figure(figsize=(15, 4), dpi=dpi)
plt.plot(x, y, color='tab:red')
# Format the x-axis to show one tick per year
ax = plt.gca()
ax.set(title=title, xlabel=xlabel, ylabel=ylabel)
ax.xaxis.set_major_locator(mdates.YearLocator()) # One tick per year
ax.xaxis.set_major_formatter(mdates.DateFormatter('%Y')) # Format as 4-digit year
plt.xticks(rotation=45) # Rotate labels for clarity
plt.tight_layout()
plt.show()
# Plotting with updated function
plot_df(df, x=df['date'], y=df['passengers'], title='Number of US Airline Passengers (1949–1960)')

Plotting the data allows us to identify key patterns—such as long-term trends, seasonal fluctuations, or irregular movements—which will inform our choice of decomposition method.
Time series data can typically be broken down into four core components:
Base Level + Trend + Seasonality + Error
These components help us interpret the underlying structure of the series:
- Trend: The long-term direction in the data, whether increasing, decreasing, or stable over time.
- Seasonality: Repeating, predictable patterns occurring at fixed intervals (e.g., monthly, weekly, or daily), often linked to calendar effects.
- Cyclic Behavior: Fluctuations that recur over irregular, longer-term periods, typically tied to economic or structural forces (e.g., market cycles).
- Error (Irregular Component): Random, unpredictable variations not explained by the other components.
In the plot above, we observe a clear upward trend in the number of airline passengers over time—indicating a growing demand in air travel.
Additive vs. Multiplicative Decomposition
Now we can try to decompòse the following time series into all four parts:
from statsmodels.tsa.seasonal import seasonal_decompose
import matplotlib.pyplot as plt
# Perform decompositions
multiplicative_decomposition = seasonal_decompose(df['passengers'], model='multiplicative', period=30)
additive_decomposition = seasonal_decompose(df['passengers'], model='additive', period=30)
# Plot Multiplicative Decomposition
plt.rcParams.update({'figure.figsize': (16, 12)})
fig1 = multiplicative_decomposition.plot()
fig1.suptitle('Multiplicative Decomposition', fontsize=20, fontweight='bold')
# Customize subplot fonts
for ax in fig1.axes:
ax.title.set_fontsize(14)
ax.title.set_fontweight('bold')
ax.set_xlabel(ax.get_xlabel(), fontsize=20)
ax.set_ylabel(ax.get_ylabel(), fontsize=20)
ax.tick_params(axis='both', labelsize=15)
plt.tight_layout(rect=[0, 0.03, 1, 0.95])
plt.show()
# Plot Additive Decomposition
fig2 = additive_decomposition.plot()
fig2.suptitle('Additive Decomposition', fontsize=25, fontweight='bold')
for ax in fig2.axes:
ax.title.set_fontsize(14)
ax.title.set_fontweight('bold')
ax.set_xlabel(ax.get_xlabel(), fontsize=20)
ax.set_ylabel(ax.get_ylabel(), fontsize=20)
ax.tick_params(axis='both', labelsize=15)
plt.tight_layout(rect=[0, 0.03, 1, 0.95])
plt.show()
Obtaining the following plots:

After decomposing the time series, we compare the performance of two common approaches:
- The additive decomposition shows residuals that still contain some visible patterns, suggesting it doesn’t fully capture the variability in the data.
- The multiplicative decomposition, on the other hand, produces more random residuals—an indication of a better fit for this specific dataset.
Main Conclusions
For this particular time series, the multiplicative model provides a more accurate separation of signal and noise.
Pro Tip: Always examine the residuals when performing decomposition. Well-behaved (random-looking) residuals are a good sign that the chosen model captures the underlying structure effectively.
You can go check my Jupyter Notebook on Github repository.
