I am trying to separate seasonality, trend and residual from timeseries 'XYZ.csv' (sales data collected over 2 years of time).
[XYZ.csv contains 2 columns - date and sales. Date has been set as an index within the code.]
import pandas as pd
import statsmodels.api as sm
df = pd.read_csv('XYZ.csv')
df.date=pd.to_datetime(df.date)
df.set_index('date',inplace=True)
res = sm.tsa.seasonal_decompose
(df.colA.interpolate(),freq=?, model='additive')
resplot= res.plot()
observed = res.observed
seasonality = res.seasonal
This code works fine. The only trouble is to understand how to calculate the frequency for this time series? And if there is any predefined way in which I can do it. Thanks for any help/suggestions in advance!