Add hours with datetime.timedelta(hours=1)

I saw in a related post that you cant add with .timedelta less than 24 hours but i need to really add a hour to my time, my code is this:

Hour =df['Hour'].values[0]
16:42:00
The column Hour is a datetime.time

And im trying to add one hour like this :

from datetime import date
HourPlus=datetime.datetime.combine(date.today() +datetime.timedelta(hours=1),Hour)

But only works if i add days=1 and not hours, how can i solve this ?

from datetime import date
HourPlus=datetime.datetime.combine(date.today() +datetime.timedelta(days=1),Hour)
2021-04-14 16:42:00

Answer

The heart of the problem in the question is that

date.today() +datetime.timedelta(hours=1)

fails to add an hour because datetime.date is a date not a datetime. So, adding an hour to the date doesn’t change the date.

You need to have a datetime.datetime object to meaningfully add an hour.

>>> import datetime 
>>> x = datetime.date.today()
>>> x
datetime.date(2021, 4, 13)
>>> x + datetime.timedelta(hours=1)
datetime.date(2021, 4, 13)
>>> y = datetime.datetime.today()
>>> y
datetime.datetime(2021, 4, 13, 14, 32, 41, 989496)
>>> y + datetime.timedelta(hours=1)
datetime.datetime(2021, 4, 13, 15, 32, 41, 989496)
>>>