From the course: Python for Time Series Forecasting

Unlock this course with a free trial

Join today to access over 24,800 courses taught by industry experts.

Seasonal decompose with Statsmodels

Seasonal decompose with Statsmodels - Python Tutorial

From the course: Python for Time Series Forecasting

Seasonal decompose with Statsmodels

- [Instructor] Decomposition. In this lesson, I'll show you how to compute both the additive model and the multiplicative model, where each one of these components are calculated, whether you add them up or you multiply them. The function to produce these components is inside the statsmodels library. Let's import it, and produce the results of this chart where we see the trends, the seasonal component and the residuals out of this data that represents the monthly energy generation from solar energy. Inside the module, we look for tsa and the function seasonal_decomposed. Looking in the help, we see the first parameter is the x, which is the array of the time series values. In the model, we can place additive or multiplicative, and very important, the periods parameter, which will be 12, since we are working with monthly data, although we may skip it because our pandas object that we will pass to the function, in this case, our series, already has the frequency information so that the…

Contents