The 365 Data Science team is proud to invite you to our own community forum. A very well built system to support your queries, questions and give the chance to show your knowledge and help others in their path of becoming Data Science specialists.
Ask
Anybody can ask a question
Answer
Anybody can answer
Vote
The best answers are voted up and moderated by our team

Frequency error on Time Series seasonal_decompose method

Frequency error on Time Series seasonal_decompose method

1
Vote
1
Answer

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 Answer

365 Team
0
Votes

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

Thanks, Vik! Will try the above. Appreciate it. Update! Issue was package of stats models was not compatible with my command line. Had to use seasonal_decompose instead of sd. Thanks again!

6 months
×
LAST CHANCE
Ready to Learn Data Science?
50% OFF