-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
COMPAT: Updated method call for _Openpyxl22Write.write_cells() for Openpyxl =>2.4.0 #14519 #14539
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
Conversation
Updated _Openpyxl22Writer.write_cells() to use new coordinate call method wks['coordinate'] instead of wks.cell() in accordance with https://openpyxl.readthedocs.io/en/default/tutorial.html#accessing-one-cell in the newest release of Openpyxl (2.4.0 and later).
|
@jorisvandenbossche if you could point me to where you think the UserWarning might be stemming from in pandas codebase then I'd be more than happy to take a look at it. I just went the most obvious edit that I could find and only that used this wks.cell(coordinate) method call. If you know of any other sources for the issue please let me know. |
|
@ditenberg for finding the UserWarning, you could try sticking at the top of the excel file tests. That would turn any UserWarnings into exceptions. Glancing through the test file, it looks like we use pandas/pandas/io/tests/test_excel.py Line 1970 in 7f5a45c
|
Update _Openpyxl20Writer and fixed _Openpyxl22Writer write_cells() methods. Made 20 index cells using numeric row/columns. Made 22 the same way as well (original state in current master)
Updated syntax to latest release openpyxl for retrieving cell values
|
@TomAugspurger I put your suggested code into the pandas/io/tests/test_excel.py file and changed the cell value retrieval syntax in your mentioned location and a few others throughout the file. After running |
|
@TomAugspurger There are deeper issues with the _OpenpyxlXXWriter since they are deemed incompatible in the test_excel.py comments to be skipped during tests. Regardless, with commits the UserWarning no longer appears after test. |
| ] | ||
|
|
||
| with ensure_clean('.xlsx') as path: | ||
| warnings.simplefilter('error', UserWarning) |
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.
use assert_produces_warning
| self.sheets[sheet_name] = wks | ||
|
|
||
| for cell in cells: | ||
| colletter = get_column_letter(startcol + cell.col + 1) |
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.
all of these changes need to be back-compat. so need to switch code based on the version.
|
@ditenberg can you rebase / update. this needs to be back compat (easy enough, you simply have a version check on the import and branch based on that). |
|
@ditenberg can you update this? |
|
closing as stale, but would like you to update if possible. |
git diff upstream/master | flake8 --diffUpdated _Openpyxl22Writer.write_cells() to use new coordinate call method wks['coordinate']
instead of wks.cell() in accordance with https://openpyxl.readthedocs.io/en/default/tutorial.html#accessing-one-cell
in the newest release of Openpyxl (2.4.0 and later).
I did not know how to write a true test for this fix since it involves Excel file I/O and pandas does not currently supporting reading in .xlsx as far as I know. The best I could do is use it with openpyxl 2.4.0 install on my machine and passing a small dataframe into an .xlsx. Please let me know if you have any suggestions on how to better test this.