STL stands for seasonal and trend decomposition using LOESS. STL is a time-series decomposition method that can decompose an observed signal into a trend, seasonality, and residual. It can estimate non-linear relationships and handle any type of seasonality. The statsmodels.tsa.seasonal subpackage offers the seasonal_decompose method for splitting a given input signal into trend, seasonality, and residual.
Let's see the following example to understand STL decomposition:
# import needful libraries
import pandas as pd
import matplotlib.pyplot as plt
from statsmodels.tsa.seasonal import seasonal_decompose
# Read the dataset
data = pd.read_csv('beer_production.csv')
data.columns= ['date','data']
# Change datatype to pandas datetime
data['date'] = pd.to_datetime(data['date'])
data=data.set_index('date')
# Decompose the data
decomposed_data = seasonal_decompose(data, model='multiplicative')
# Plot decomposed data...