Skip to content
Advertisement

freq parameter not presented in seasonal_decompose function

let us suppose we have following code :

JavaScript

result of dataframe is given below :

JavaScript

also it returns following error :

JavaScript

instead i know that there is keyword period, are they same?generally we know that period is 1/frequency, but in this case how should i define period? or how can i create frequency index? please help me

Advertisement

Answer

The period argument in seasonal_decompose is periodicity i.e after how long things start to repeat.

For example, time series data with a frequency of 1 hour would have a period of 24. If frequency was 3 hours, period would be 8 = (24 / 3).

In your case, it seems that the frequency is business days (Mon – Fri), which implies a period of 5.

Yeah, it seems that both weekends and holidays have been removed. But the asfreq method can be used to forwad-fill/back-fill blanks. Specifying a period of 5 means that you expect values e.g on Mondays to be somewhat similar

If the input data is a pandas.Series with a datetime index, you might not need to specify a period:

JavaScript

But be warned, the statsmodels.tsa.tsatools.freq_to_period function used internally in seasonal_decompose ignores the scale of frequency i.e. 3H and H are both treated as H. You can check this with:

JavaScript

I would recommend specifying the period argument directly in seasonal_decompose (5 in this case).

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement