Menu Close

How to convert Python Pandas timezone-aware DateTimeIndex to naive timestamp, but in certain timezone?

To convert Python Pandas timezone-aware DateTimeIndex to naive timestamp, but in certain timezone, we call tz_localize.

For instance, we write

pd.Timestamp('2019-10-07 10:30:19.428748+0200', tz='Europe/Brussels')

to convert the timestamp with the tz argument set to the timezone we want to convert to.

We can call tz_localize to convert the timezone to naive local time

pd.Timestamp.now(tz='Europe/Brussels').tz_localize(None)

And we can call tz_convert with None to convert the timestamp with a given time zone to UTC with

pd.Timestamp.now(tz='Europe/Brussels').tz_convert(None) 
Posted in Python, Python Answers