-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
ENH: Add autofilter parameter to DataFrame.to_excel #62928
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
base: main
Are you sure you want to change the base?
Conversation
|
Hi @rhshadrach, I hope you’re doing well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! I think this is looking good. Unfortunately it seems that odfpy does not provide a reasonable way to add an autofilter. If that is the case, I think we should raise when autofilter=True is passed and this engine is used. Can you add this and a test.
Can you also add tests for:
- nonzero startrow / startcol
- A DataFrame with MultiIndex columns (also called a hierarchical index) with both
merge_cells=Trueandmerge_cells=False.
Okay, Im working on them now |
2558c20 to
e4012f0
Compare
|
Hi @rhshadrach . |
…ge for xlsxwriter/openpyxl; keep engine_kwargs semantics intact
…ter and a user guide snippet
- Remove duplicate to_excel function code in generic.py - Add NotImplementedError for odfpy engine when autofilter=True - Remove broad exception handling from autofilter implementations - Add comprehensive tests for nonzero startrow/startcol - Add tests for MultiIndex columns with merge_cells=True and False - Improve tests to verify each column has autofilter - Remove redundant test_to_excel test - Remove redundant pytest.importorskip from test functions
…port - Keep ExcelWriter and ExcelFormatter in TYPE_CHECKING for type hints - Import both at runtime inside to_excel method to avoid circular import
8e3abb2 to
44010db
Compare
|
@antznette1 - tests are failing, are you able to run them locally? Also I want to mention #62994 is looking to add the same feature and appears close to being ready. |
Yes, I can run locally. I realized my branch currently adds tests that assert behavior for an API not on main yet (and I left some debug prints). I’m cleaning that up now. |
@rhshadrach
Adds an
autofilterparameter toDataFrame.to_excel()to enable Excel autofilterover the header row and data range when writing files.
Usage:
Supports
xlsxwriterandopenpyxlengines. Whenautofilter=True, applies anautofilter over the written data range (header row through last data row).
Closes #62651