Skip to content
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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

fawazahmed0
Copy link

@fawazahmed0 fawazahmed0 commented Jul 20, 2024

Copy link
Member

@rhshadrach rhshadrach left a 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.

@rhshadrach rhshadrach added Bug Dtype Conversions Unexpected or buggy dtype conversions IO JSON read_json, to_json, json_normalize labels Jul 23, 2024
@@ -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")
Copy link
Member

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.

Copy link
Author

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

Copy link
Contributor

github-actions bot commented Sep 1, 2024

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.

@github-actions github-actions bot added the Stale label Sep 1, 2024
@rhshadrach
Copy link
Member

pre-commit.ci autofix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions IO JSON read_json, to_json, json_normalize Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

read_json reads large integers as strings incorrectly if dtype not explicitly mentioned
2 participants