I am new at python.
I have a df called dates which is storing dates. I want to add an extra hour to the whole column.
0 2011-01-07
1 2011-01-07
2 2011-01-10
3 2011-01-10
4 2011-01-10
Name: dates, Length: 15644, dtype: datetime64[ns]
This is the code I want to apply on it
from datetime import datetime , timedelta
timestamp = pd.Timestamp('2023-01-01 12:00')
new_timestamp = timestamp + timedelta(days=0, hours=1)
The code works fine on its own but how can I apply these functions on my df which is stored as a pandas series?
Please help. Thanks!!!
As far as I understood you want to, given a certain column filled with dates, add an hour to each observation.
With
timedeltaand alambdafunction you can do the following:print(dates.head().to_markdown())
Result: