-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
CLN: remove redundant openpyxl type conversions #39782
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
openpyxl already converts cell values to Python types, preferring integers where possible. For backwards-compatibility, we have to convert integers back to float if not `convert_float`
elif cell.data_type == TYPE_ERROR: | ||
return np.nan | ||
elif cell.data_type == TYPE_BOOL: | ||
return bool(cell.value) |
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.
Are there tests for bool/int/etc?
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.
Yes there are. If I break the function to return
- all numbers as float, 198 tests fail
- all numbers as int, 211 tests fail
- all bools as int, 20 tests fail
- all bools as str, zero tests fail because TextParser does its own conversions
Thanks for taking them time to look at my first pull request. Let me know if there's anything that needs to be improved.
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.
Great - thanks for checking.
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.
lgtm - very nice cleanup.
elif cell.data_type == TYPE_ERROR: | ||
return np.nan | ||
elif cell.data_type == TYPE_BOOL: | ||
return bool(cell.value) |
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.
Great - thanks for checking.
thanks @ahawryluk |
openpyxl already converts cell values to Python types, preferring
integers where possible. For backwards-compatibility, we have to convert
integers back to float if not
convert_float