Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

value error in python statsmodels.tsa.seasonal

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?

like image 739
mooneral Avatar asked Nov 24 '16 20:11

mooneral


1 Answers

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!

like image 134
mooneral Avatar answered Oct 12 '22 00:10

mooneral