-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
to_excel can't handle index with time zones #7056
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
cc @jmcnamara does excel support tz's in dates even? not sure what this should do |
No. Excel doesn't have any support for timezones. I don't really know how this should be handled. |
ok....maybe should just report a better error for now @sboehler what do you think it should do? |
I'd expect either localized or UTC timestamps (both without tz information) Agree? 2014-05-06 18:36 GMT+02:00 jreback [email protected]:
|
that makes sense, so choices I think are:
|
or:
The global "convert_timezones" argument is problematic with several columns of timestamps - a user might want to output multiple columns with local timestamps and UTC timestamps to address Excels lack of tz handling. |
ok... @sboehler so this is pretty straightfoward....PR? |
I just noticed, the bug does not occur when I uninstall xlsxwriter! Pandas must be internally choosing the xlsx engine, depending on what's available in terms of packages, and use something else if xlsxwriter is not present. The default seems to be to output the localized timestamp, omitting the timezone info. @jreback As you can see from my github profile I have no experience with developing pandas, but I am happy to give it a go. This could take a few days, however... |
you can specify give it a go and let us know any issues |
from #7060
|
to clarify here, @kay1793 what would an API for this be like? e.g. need to have 2 ways of converting a timezone-aware Series/Index (e.g. raise if the underlying engine does not support, which most/all doen't ATM, or stringify to a isoformat). |
I can't say about the API, stringify to iso would work perfect for my needs and can still be sorted. Coercing to UTC would also be ok if there was a big fat warning came with it. |
using |
Could be an intermediate solution to add the warning and a note on the docs? |
Hello everyone,
A solution to this bug would be to localize epoch to the timezone of dt_obj, so that the timedelta is correct whatever the time zone is, and time-zoned datetimes can be handled, even if there's no notion of timezone in the resulting xlsx file. what do you think about this ? (this bug also appears with normal columns that are not indexes) |
@misterjoa you actually just want naive zones, IOW, I maybe could see an option |
thank you for your answer. In fact, I want the user of an excel file to be shown the correct date and time in an arbitrary time zone. To do so and avoid the current issue, I do the following before exporting to xlsx using xlsxwriter, using a column with strings containing UTC timestamp data : (Paris is the target zone)
So having an option like you say would be really great |
Hi
Something is wrong when trying to save a dataframe with tz-aware timestamps to xlsx, using pd.Dataframe.to_excel:
yields an exception on my system:
Using Python 3.4.0 on Arch Linux, list of installed packages:
The text was updated successfully, but these errors were encountered: