在TimeSeries Dataframes Python中更改日期

在TimeSeries Dataframes Python中更改日期,python,dataframe,Python,Dataframe,我正在尝试更改每小时时间序列的日期部分。我用这种方法来做这件事 import numpy as np import pandas as pd np.random.seed(0) df_volume = pd.DataFrame(np.random.randint(60, 100, (24,4)), index=pd.date_range('2015-08-11', periods=24, freq='H'), columns='Col1 Col2 Col3 Col4'.split()) #d

我正在尝试更改每小时时间序列的日期部分。我用这种方法来做这件事

import numpy as np
import pandas as pd

np.random.seed(0)
df_volume = pd.DataFrame(np.random.randint(60, 100, (24,4)), index=pd.date_range('2015-08-11', periods=24, freq='H'), columns='Col1 Col2 Col3 Col4'.split())

#df_volume.reset_index(inplace=True)
df_volume.index = pd.to_datetime('2015-01-01') + pd.to_datetime(df_volume.index,format='%H:%M:%S')
print (df_volume)
错误为引发未实现错误。我不知道怎么解决这个问题。 如果我重置索引,然后尝试更改日期,则错误为时间数据0与格式“%H:%M:%S”(匹配)不匹配。请帮忙。
我有24小时的数据,我想更改日期并保持时间不变。

我不确定您想做什么,但是听起来您想更改索引的日期,而不更改小时、分钟或秒。如果这是你正在寻找的,这应该做它。您可以根据需要更改日期或月份

from pandas.tseries.offsets import DateOffset
df_volume.index = df_volume.index - DateOffset(months=7, days=10)