'Pandas | time conversions

I have a question concerning time conversion in Python/Pandas. The following is not entirely clear to me.

t1 = datetime.datetime(2021,9,15,6,0)
tt1 = t1.timestamp()
pd.to_datetime(tt1,unit='s')
[1] Timestamp('2021-09-15 04:00:00')

What do I have to change to get the following result:

[1] Timestamp('2021-09-15 06:00:00')

Thank you!



Solution 1:[1]

You can offset your time difference to GMT with

pd.to_datetime(tt1, unit='s') + pd.Timedelta('02:00:00')

See this answer for more details.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tobi208