首页 > 解决方案 > 使用 STL 分解时间序列会出错

问题描述

我的代码

stl_fcast = forecast(nottem_stl, steps=12, fc_func=seasonal_naive, seasonal = True)

错误信息

 ValueError                                Traceback (most recent call last)
<ipython-input-95-39c1ef0e911d> in <module>
      1 stl_fcast = forecast(nottem_stl, steps=12, fc_func=seasonal_naive,
----> 2                      seasonal = True)
      3 
      4 stl_fcast.head()

~/opt/anaconda3/lib/python3.7/site-packages/stldecompose/stl.py in forecast(stl, fc_func, steps, seasonal, **fc_func_kwargs)
    102 
    103     # forecast index starts one unit beyond observed series
--> 104     ix_start = stl.observed.index[-1] + pd.Timedelta(1, stl.observed.index.freqstr)
    105     forecast_idx = pd.DatetimeIndex(freq=stl.observed.index.freqstr,
    106                                     start=ix_start,

pandas/_libs/tslibs/timedeltas.pyx in > pandas._libs.tslibs.timedeltas.Timedelta.__new__()
ValueError: Units 'M' and 'Y' are no longer supported, as they do not represent unambiguous timedelta values durations.

此代码曾经在旧版本的 Pandas - 0.25 中工作。

感谢任何帮助,谢谢。

标签: pythonpandasforecasting

解决方案


推荐阅读