-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
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
ENH: Support for Excel features when writing #45572
Comments
might also help #44868 |
Proposal 2 would go well together with making |
What would prevent us from extending the styler class to support most of these? |
To me 2 makes more sense as it avoids a lot of complexity while allowing end-users to customize to their heart's content. In the past I have used to_excel followed by my own custom code to add features that cannot be directly accomplished using pandas., essentially 3(b) |
+1 on option 2 |
I'm also +1 on option 2. For what it's worth, we took a similar approach
for reading hidden sheets (#19842). We showed how to check for hidden-ness
using the engine for that file format without actually adding the feature
to pandas for all 4 engines.
…On Sun., Jan. 23, 2022, 4:07 p.m. Jeff Reback, ***@***.***> wrote:
+1 on option 2
—
Reply to this email directly, view it on GitHub
<#45572 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AMAZB7T3JQWMCXMYUDKRS73UXSCZXANCNFSM5MTU3YRA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I think some of these would just require a lot of complicated, and non-universal, code to get it working. And it would have have to be coded for Styler, and then parsed by the At the moment styles and number formats to excel is a hacked on component. Styler does not have its own renderer for excel like it does for HTML, LaTeX and String. For a user keen to do these things, I think its better to just open up some generic API and let them customise. Providing a user guide with good examples is probably worth a lot more. +1 for Proposal 2. |
+1 for Proposal 2. I also think we should expose |
tldr: how to set the
|
Context
Currently
DataFrame.to_excel
supportsfreeze_panes
, and there are requests to support other Excel features (#42560). I've gone through the features of openpyxl and Xlsxwriter, here are other Excel features that pandas might support:Not listed here are styles as I believe the
styler
supports most of these (cc @ahawryluk).It seems difficult to justify pandas supporting some of these, but not others. On the other hand, implementing all or even just some of them for each engine adds a lot of complexity and maintenance burden to pandas. I haven't checked, but it may also be the case that some features are supported by certain engines but not by others.
While pandas documents the
writer
ofExcelWriter
as having no public attributes, third party engines document usingwriter.book
e.g. xlsxwriter.Proposal 1: Add more arguments to write_excel.
Add other arguments to
to_excel
, such as autofilter, hiding row/columns/worksheets, conditional formatting. At least these three I perceive to be commonly used.This is the most user friendly option in that it allows users access to these features with a single function call and the ability to switch engines without having to refactor their code. However as mentioned above, this adds complexity to pandas and is a maintenance burden.
Proposal 2: Make
writer.book
public, prefix all or most other attributes with an_
.This would allow users to use the features that the engine supports directly with
ExcelWriter
, e.g.This would require refactoring the
writer.sheets
as in current state it can get out of sync withwriter.book
if e.g. a user doeswriter.book.add_sheet(...)
.This proposal is less complex/maintenance than Proposal 1, more user friendly than Proposal 3.
Proposal 3: Don't support any Excel features.
Users wanting these features would either be required to (a) write their DataFrames directly with the engine of choice or (b) write their DataFrames with pandas, then open a book with the engine of their choice if the engine supports modifying existing Excel workbooks.
Less complex/maintenance than Proposal 2, but also less user friendly.
I am currently in favor of Proposal 2. I also see a mix of Proposal 1 and Proposal 2 as viable, where some features are supported directly as arguments in
to_excel
with other features require the user to usewriter.book
for others.cc @pandas-dev/pandas-core
The text was updated successfully, but these errors were encountered: