-
-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
Fix https://github.com/pandas-dev/pandas/issues/20608 #59284
base: main
Are you sure you want to change the base?
Conversation
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 - please add a test.
@@ -1221,7 +1222,7 @@ def _try_convert_data( | |||
if len(data) and data.dtype in ("float", "object"): | |||
# coerce ints if we can | |||
try: | |||
new_data = data.astype("int64") | |||
new_data = backup_data.astype("int64") |
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.
Instead of this, it seems to me we should first try to convert the data to integer on L1206 above, then if that fails try float. That way we aren't converting to float then back to int unnecessarily.
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.
if we do int
first and then float
. It will create issue for decimals. eg: 25.5
will become 25
This pull request is stale because it has been open for thirty days with no activity. Please update and respond to this comment if you're still interested in working on this. |
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.