相关疑难解决方法(0)

时间序列分析 - 不均匀间隔的测量 - 熊猫+ statsmodels

我有两个numpy数组light_points和time_points,并希望对这些数据使用一些时间序列分析方法.

然后我尝试了这个:

import statsmodels.api as sm
import pandas as pd
tdf = pd.DataFrame({'time':time_points[:]})
rdf =  pd.DataFrame({'light':light_points[:]})
rdf.index = pd.DatetimeIndex(freq='w',start=0,periods=len(rdf.light))
#rdf.index = pd.DatetimeIndex(tdf['time'])
Run Code Online (Sandbox Code Playgroud)

这有效,但没有做正确的事情.实际上,测量不是均匀的时间间隔,如果我只是将time_points pandas DataFrame声明为我的帧的索引,我会收到一个错误:

rdf.index = pd.DatetimeIndex(tdf['time'])

decomp = sm.tsa.seasonal_decompose(rdf)

elif freq is None:
raise ValueError("You must specify a freq or x must be a pandas object with a timeseries index")

ValueError: You must specify a freq or x must be a pandas object with a timeseries index
Run Code Online (Sandbox Code Playgroud)

我不知道如何纠正这个问题.此外,似乎大熊猫TimeSeries已被弃用.

我试过这个:

rdf = pd.Series({'light':light_points[:]})
rdf.index = pd.DatetimeIndex(tdf['time'])
Run Code Online (Sandbox Code Playgroud)

但它给我一个长度不匹配: …

python machine-learning time-series pandas statsmodels

9
推荐指数
1
解决办法
1万
查看次数