1

I have dataframe

    (index)     purchased   sold        price
2013-04-04  14.865494   14.800361   12.762369
2013-04-05  15.191654   15.296572   12.777120
2013-04-06  15.402671   15.844089   12.773146
2013-04-07  15.840517   15.437765   12.780774

and the indices are df.index:

DatetimeIndex(['2013-04-04', '2013-04-05', '2013-04-06', '2013-04-07',
           '2013-04-08', '2013-04-09', '2013-04-11', '2013-04-12',
           '2013-04-14', '2013-04-15',
           dtype='datetime64[ns]', name='date',length=273,freq=None)

I need to write a model to reduce seasonality in the data using decomposing: i wrote this piece of code for:

from statsmodels.tsa.seasonal import seasonal_decompose
decomposition = seasonal_decompose(df)

trend = decomposition.trend
seasonal = decomposition.seasonal
residual = decomposition.resid

but it raise an error for decomposition = seasonal_decompose(df)

ValueError: You must specify a freq or x must be a pandas object with a timeseries index

What is the problem? Is there any other way to do this?

IanS
  • 15,771
  • 9
  • 60
  • 84
rvMMan
  • 11
  • 1

0 Answers0