Strip timezone info in pandas

Maybe help strip last 6 chars:

print df
                    datetime
0  2015-12-01 00:00:00-06:00
1  2015-12-01 00:00:00-06:00
2  2015-12-01 00:00:00-06:00

df['datetime'] = df['datetime'].astype(str).str[:-6]
print df
              datetime
0  2015-12-01 00:00:00
1  2015-12-01 00:00:00
2  2015-12-01 00:00:00

If your series contains only datetimes, then you can do:

my_series.dt.tz_localize(None)

This will remove the timezone information ( it will not change the time) and return a series of naive local times, which can be exported to excel using to_excel() for example.

Tags:

Python

Pandas