我有一个我想分解的时间序列. 数据集(火车-rame)示例(股价):
Date Close
7389 2014-12-24 104.589996
7390 2014-12-26 105.059998
7391 2014-12-29 105.330002
7392 2014-12-30 105.360001
7393 2014-12-31 104.5700
这是我的代码:
train_dec = copy.deepcopy(train)
train_dec.index = pd.to_datetime(train_dec['Date'])
train_dec.index.freq = 'D'
# Transf或m DataFrame into a Series
train_series = train_dec['Close']
train_decomposition = seasonal_decompose(train_series, model='additive')
train_trend = train_decomposition.trend
train_seasonal = train_decomposition.seasonal
train_residual = train_decomposition.resid
我try 了不转换为系列并使用它.try 将频率设置为"D".
我不断出现错误,例如:
Value错误:来自传递值的推断频率无与传递频率D一致
或
ValueErr或: You must specify a period 或 x must be a pandas object with a PeriodIndex 或 a DatetimeIndex with a freq not set to None
当我不设置频率时.
Maybe it is because the data have gaps (weekends) when there is no data point (stock price). Should I convert it to a weekly f或mat? But how can I do this if there are gaps (e.g. if I have removed outliers)?
这一定是一些微不足道的事情,但我看不到解决方案.
非常感谢您的帮助!