Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
ENH: Adding engine_kwargs to DataFrame.to_excel #53220
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: Adding engine_kwargs to DataFrame.to_excel #53220
Changes from 20 commits
31af5a2
5943856
4a7994f
1f2ef68
72c5f80
5ad0e10
a1799a1
1d6677f
cca1f6c
7d42a15
0e86804
b016edd
7c63fc9
954a727
9938978
b095e10
f3dd277
bbe1d3b
010e224
7e023ad
5b76c06
c014e4f
e31ec6a
50ef9f8
cbad00f
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
For xlsxwriter and the append mode of openpyxl, I would not expect this error message. It appears that
foo
is attempting to be passed toOpenpyxlWriter.__init__
rather than stored in engine_kwargs. Is that the case?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.
@rhshadrach For
openpyxl.load_workbook
, we are getting the correct error message in my unit test ofload_workbook() got an unexpected keyword argument 'foo'
For xlsxwriter (there is no append mode) and the write mode of openpyxl, both methods are passed to
<engine>.Workbook()
.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.
@rhshadrach Yeah looking at the workbook class being instantiated in both
_xlsxwriter.py
and_openpyxl.py
, the error message handling should be correct.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.
I see - the
__init__
that raises is part of the engine. Can you check the message for e.g.Workbook.__init__()
to make sure we're not raising in the wrong place.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.
Sure!
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.
Looks like the traceback was changed in Python 3.10; in Python 3.9 you only get
__init__()...
. Can you importPY310
from pandas.compat._constants and check forWorkbook.__init__
when true? Note this will be true whenever the Python version is 3.10 or greater.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 @rhshadrach! I was going down a rabbit hole last night troubleshooting this. I was beginning to think that the issue had something to do with how we were raising the Type error in
_openpyxl.py
and_xlsxwriter.py
without an Exception clause.