I was trying out seasonal_decompose to decompose my time series. The data is perfect time series with frequency of '2T' i.e. 2 Minutes. From file tsatools.py (site-pkgs\statsmodels\tsa\tsatools.py), in line 655, I added the following. _ elif freq == 'T': return 6024752_ I added this from the following inference: Freq A means 1 year hence it returns 1. Q means quaterly and hence returns 4 M means monthly and hence returns 12 and so on. Therefore, T means per minute, hence 60247*365
When I do the above, I get following error: ValueError: Inferred frequency of index and frequency don't match. This function does not re-sample From line 70 in seasonal.py (statsmodel\tsa\seasonal.py) Because : variable freq is : <2 * Minutes> And variable pfreq is 2T 524160.
I mean seasonal decompose should be able to decompose timeseries of 1min frequency, and something seems to have changed. Please have a look at it, and let me know if I'm missing anything.
I got the same problem, I think it's an internal problem since I test all the index data type. At the end, I tried this and it works.
import statsmodels.api as sm
decompfreq = 6*12
decomposition = sm.tsa.seasonal_decompose(ts3_log.values,freq=decompfreq)
trend = decomposition.trend
decompfreq is calculated based on the time window, which is 10 mins, so the freqency actually is half a day.
Hope this would help you
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