Darts how to build Timeseries - ValueError: cannot reindex from a duplicate axis
Darts how to build Timeseries - ValueError: cannot reindex from a duplicate axis
我正在使用 DARTS 运行 预测模型
我有两列:
TIME, QUANTITY
值按季度分配,但有缺失值。
2006-01-01 13.0
2006-04-01 2.0
2007-0-01 3.0
2007-10-01 11.0
我想构建时间序列
_df.index = _df[TIME]
series = TimeSeries.from_dataframe(_df,
#time_col=TIME,
value_cols=[QUANTITY],
freq='Q',
fill_missing_dates=True)
series = fill_missing_values(series=series, fill=0.0)
我得到了
/usr/local/lib/python3.8/dist-packages/pandas/core/indexes/base.py in
_can_reindex(self, indexer) 3281 # trying to reindex on an axis with duplicates 3282 if not self.is_unique and len(indexer):
-> 3283 raise ValueError("cannot reindex from a duplicate axis") 3284 3285 def reindex(self, target, method=None, level=None, limit=None, tolerance=None):
ValueError: cannot reindex from a duplicate axis
同时删除评论
time_col=TIME,
我遇到了同样的错误。
使用 pandas 插值法解决
_df.index = _df[c_time]
#_df = _df[c_quantity]
_df = _df.resample('Q').sum().interpolate(method='time')
我正在使用 DARTS 运行 预测模型
我有两列:
TIME, QUANTITY
值按季度分配,但有缺失值。
2006-01-01 13.0
2006-04-01 2.0
2007-0-01 3.0
2007-10-01 11.0
我想构建时间序列
_df.index = _df[TIME]
series = TimeSeries.from_dataframe(_df,
#time_col=TIME,
value_cols=[QUANTITY],
freq='Q',
fill_missing_dates=True)
series = fill_missing_values(series=series, fill=0.0)
我得到了
/usr/local/lib/python3.8/dist-packages/pandas/core/indexes/base.py in
_can_reindex(self, indexer) 3281 # trying to reindex on an axis with duplicates 3282 if not self.is_unique and len(indexer):
-> 3283 raise ValueError("cannot reindex from a duplicate axis") 3284 3285 def reindex(self, target, method=None, level=None, limit=None, tolerance=None):
ValueError: cannot reindex from a duplicate axis
同时删除评论
time_col=TIME,
我遇到了同样的错误。
使用 pandas 插值法解决
_df.index = _df[c_time]
#_df = _df[c_quantity]
_df = _df.resample('Q').sum().interpolate(method='time')