0% found this document useful (0 votes)
79 views

Time Series Decomposition - ETS Model Using Python

This Python code is analyzing time series sales data from a CSV file. It loads the data into a DataFrame, sets the Month column as the index, and plots the raw data. It then performs a seasonal decomposition to separate the data into trend, seasonal, and residual components. It plots the trend and seasonal components separately.

Uploaded by

ante mitar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
79 views

Time Series Decomposition - ETS Model Using Python

This Python code is analyzing time series sales data from a CSV file. It loads the data into a DataFrame, sets the Month column as the index, and plots the raw data. It then performs a seasonal decomposition to separate the data into trend, seasonal, and residual components. It plots the trend and seasonal components separately.

Uploaded by

ante mitar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline

df = pd.read_csv('sales.csv',index_col='Month')
df.head()
df.plot()

df.index = pd.to_datetime(df.index)
df.head()

from statsmodels.tsa.seasonal import seasonal_decompose


final = seasonal_decompose(df['Sales'],model='multiplicative')

final.trend.plot()
final.seasonal.plot()

fig = final.plot()

You might also like