Last answered:

27 Mar 2020

Posted on:

27 Mar 2020

1

Resolved: Frequency error on Time Series seasonal_decompose method

Hello! When following the Time Series with Python course on the seasonality lecture, the method seasonal_decompose produces an error saying the frequency is not discernible. 
'Index' object has no attribute 'inferred_freq'
 I have tried the following troubleshooting methods:
  • Check to make sure the instruction was entered correctly
  • Reset the frequency of the series in the lecture from business days to just days to see if pd.infer_freq would pick it up
  • Used the original S&P data set column
  • Use integer index instead of date index 
Any guidance would be much appreciated.
1 answers ( 0 marked as helpful)
Instructor
Posted on:

27 Mar 2020

0

Hey Sia,

Thanks for reaching out!

This error occurs when the index column is not a series of dates with a set frequency (or when there are missing values). Hence, the easiest and mos straightforward solution is to fill out the data and set the frequency prior to setting the "date" column as the index.

df_comp = df_comp.asfreq('b')
df_comp = df_comp.fillna(method='ffill')

Alternatively, you can set the frequency of the dataset by setting a value for the "freq" argument of the method:

s_dec_training = sd(data_train.newspx, model = 'additive', freq = 'b')

However, that last part might not work on all versions of the statsmodels package, so I would stick with the former solution. Additionally, you can send us your Python Notebook, so we can see what's going on.

Best,
365 Vik

Submit an answer