When analyzing financial or accounting data, you’ve likely noticed that many key metrics follow seasonal patterns: think monthly sales spikes, quarterly revenue fluctuations, or annual budgeting cycles. Seasonal decomposition is a powerful statistical method that helps isolate these patterns by breaking down a time series into three core components: the underlying trend, repeating seasonal effects, and random noise (residuals). By clearly visualizing each component, finance and accounting professionals can better understand the driving forces behind their numbers, ultimately leading to more accurate forecasts and smarter business decisions.
Historically, seasonal decomposition in Excel required elaborate workarounds involving complex formulas or extensive use of add-ins, making the process cumbersome and error-prone. Now, with Python seamlessly integrated into Excel, tasks like seasonal decomposition are dramatically easier and more approachable, even without advanced programming experience.
In this post, we’ll demonstrate exactly how straightforward this has become using Python in Excel, leveraging the well-known airlines passengers dataset. This classic dataset is ideal for our example because it clearly illustrates strong seasonal travel patterns, steady long-term growth, and common real-world scenarios such as forecasting future demand, capacity planning, or budgeting.
You can follow along with the exercise file below:
Let’s kick things off by loading our dataset, converting the ‘month’ column to a proper datetime format, and setting it as the DataFrame’s index. We’ll also standardize the frequency of our time series data to monthly intervals beginning at the start of each month (‘MS’). Maintaining a consistent frequency is crucial because seasonal decomposition techniques rely on evenly spaced data points.
Now we continue with data cleaning and setup. First, any missing passenger counts are filled using forward-fill (fillna(method='ffill')
) to ensure there are no gaps in the data that could disrupt analysis. Next, an additive seasonal-trend decomposition is applied using the STL method, breaking down the time series into three distinct components: trend (the long-term progression of passenger counts), seasonal patterns (regular, repeating fluctuations such as increased travel during holidays), and residuals (random or unexplained variations). The parameter seasonal=13
indicates the method anticipates a seasonal cycle of approximately 12 months, plus an extra period for smoothing purposes.
Finally, the observed data along with its decomposed components are neatly organized into a DataFrame, making it easy to visualize and analyze further.
Next we’ll visualize the results from our seasonal decomposition by creating a series of line charts, each representing one of the decomposed components. It sets up a figure with four vertically stacked subplots, all sharing the same horizontal axis (the time series).
Each subplot displays a different aspect of the decomposition: the original passenger counts (“Observed”), the long-term movement (“Trend”), the recurring seasonal fluctuations (“Seasonal”), and the random, unexplained variation (“Residual”). By plotting these components individually, we can clearly see and interpret how the original data breaks down, identifying patterns and anomalies in passenger volumes over time.
Based on the plot, the observed data displays the original monthly airline passenger numbers, showing a clear upward pattern along with noticeable seasonal variations. The trend component highlights the consistent long-term growth, confirming an overall increase in the number of airline passengers over the years.

The seasonal component shows consistent and repeating patterns each year, highlighting distinct peaks and troughs that probably match typical seasonal travel habits. The residual plot captures random fluctuations or noise that the other components don’t explain. It appears largely random and shows no clear patterns, indicating that our decomposition has successfully isolated the main seasonal and trend effects.
Great work gaining insights from your time series data using seasonal decomposition! This method is so useful for analyzing time-based data that when you run this data through Advanced Analysis in Copilot, you’ll likely see seasonal decomposition among the initial results. If you’re new to Copilot’s Advanced Analysis, check out this post:
In this post, we’ve explored how seasonal decomposition can reveal hidden trends, patterns, and noise in your time series data. By integrating Python directly within Excel, we simplified a traditionally complex task, making it approachable even for users without extensive coding backgrounds.
Seasonal decomposition, however, is just the beginning. You can build upon it with forecasting methods designed for seasonal data, such as SARIMA or Holt-Winters Exponential Smoothing. Additionally, Python’s advanced analytical tools within Excel can help perform sensitivity analyses or scenario planning. It’s important to note this approach assumes historical patterns remain consistent, which might not always hold true when external conditions shift.
What questions do you have about time series analysis with Python in Excel or Python in Excel more generally? Let me know in the comments.
Leave a Reply