-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Rationale
pandas/io/formats/excel.py complains that Excel does not support time-zones with invoking df.to_excel() on a dataframe with timezone-aware date-times.
The documentation tells you options={'remove_timezone': True} to the ExcelWriter initiation, but this behaviour was changed in pandas v0.25. It doesn't seem like the pandas developers will fix it [0].
How to fix it?
So, the workaround (I believe) would be to remove time zones from the date-times before converting to Excel.
I found a StackOverflow post answering this [1]. However the proposed solution didn't work, so I rewrote the code to do basically the same thing:
df.index = df.index.map(lambda d: d.replace(tzinfo=None))This example mutates the original data frame. However, with this as a starting point, figure out how to incorporate an helper in the client.
[0] pandas-dev/pandas#28921
[1] https://stackoverflow.com/questions/49198068/how-to-remove-timezone-from-a-timestamp-column-in-a-pandas-dataframe