I have this dataframe with date time indices:
ts_log:
date price_per_unit
2013-04-04 12.762369
2013-04-05 12.777120
2013-04-06 12.773146
2013-04-07 12.780774
2013-04-08 12.786835
I have this piece of code for decomposition
from statsmodels.tsa.seasonal import seasonal_decompose
decomposition = seasonal_decompose(ts_log)
trend = decomposition.trend
seasonal = decomposition.seasonal
residual = decomposition.resid
but in the line decomposition = seasonal_decompose(ts_log)
i got this error :
ValueError: You must specify a freq or x must be a pandas object with a timeseries index
Where is the problem?
After some searching i found [here][1] that, i have to add values
to ts_log.price
decomposition = seasonal_decompose(ts_log.price.values, freq=30)
Edit as to comments. Adding just freq=30
is enough!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With