熊猫月偏移重复指数

时间:2020-04-27 17:26:03

标签: python pandas

我有一个日期如下的时间序列: Ť 2017-05-30 2017-05-31

等...

我想计算1个月的拖欠额。即,将日期2017-05-31与1m之前进行比较。我尝试了此功能:

from pandas.tseries.offsets import DateOffset
spy['aum_1m'] = spy['aum_t'].shift(freq=DateOffset(months=1))

但这与]

ValueError with "cannot reindex with duplicate axis".  

我认为原因是因为如果我的时间序列为两个日期:05/30/2019和05/31/2019, 它将两个日期都移动到06/30/2019,而不是将第二个日期移动到07/01/2019。有没有办法避免重复的索引并移到下一个好日期?谢谢

0 个答案:

没有答案