You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
jonmd
changed the title
Make helper for DataFrame-to-Excel for date-times with timezoneinfo
Make helper for DataFrame-to-Excel for date-times with tzinfo
Mar 24, 2021
Rationale
pandas/io/formats/excel.py
complains that Excel does not support time-zones with invokingdf.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:
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
The text was updated successfully, but these errors were encountered: