How to calculate frequency (freq) when using seasonal decomposition()

时间:2018-04-18 18:15:54

标签: python-3.x pandas time-series statsmodels time-frequency

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!

0 个答案:

没有答案
相关问题