I have a datetime index dataframe. I want to add a few hours to it. My code:
from datetime import datetime,timedelta
df.index =
DatetimeIndex(['2019-10-01 06:58:45', '2019-10-01 06:59:00',
'2019-10-01 06:59:15', '2019-10-01 06:59:30',
'2020-07-18 09:16:30', '2020-07-18 09:16:45'],
dtype='datetime64[ns]', name='',freq=None)
# add two hours to the index datetime
df.index = df.index.time+timedelta(hours=2)
Present output:
TypeError: unsupported operand type(s) for +: 'datetime.time' and 'datetime.timedelta'