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

BUG: read_json converts Numeric Strings to Numbers #42471

Open
WillAyd opened this issue Jul 9, 2021 · 2 comments
Open

BUG: read_json converts Numeric Strings to Numbers #42471

WillAyd opened this issue Jul 9, 2021 · 2 comments
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions IO JSON read_json, to_json, json_normalize

Comments

@WillAyd
Copy link
Member

WillAyd commented Jul 9, 2021

>>> pd.read_json("""{"a": ["01", "02", "03"]}""")
   a
0  1
1  2
2  3

These are well defined by JSON to be alphanumeric strings and not integers, so its a bit unfortunate that these get cast.

Expected Output:

>>> pd.read_json("""{"a": ["01", "02", "03"]}""")
   a
0  01
1  02
2  03
@WillAyd WillAyd added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Jul 9, 2021
@asishm
Copy link
Contributor

asishm commented Jul 9, 2021

unsure if related, these issues are specifically dealing with numbers that have '_' like '23_42'

@Gdango
Copy link

Gdango commented Jul 13, 2021

I think you have to define dtype=False, otherwise it will default to True.

>>> pd.read_json("""{"a": ["01", "02", "03"]}""", dtype=False)

    a
0  01
1  02
2  03

Reference:
image

@mroeschke mroeschke added Dtype Conversions Unexpected or buggy dtype conversions IO JSON read_json, to_json, json_normalize and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Aug 21, 2021
jankaWIS added a commit to jankaWIS/lab.js that referenced this issue Sep 22, 2022
Add `dtype={'sender_id': object}` to `data` extraction using `pd.read_json` to account for the following bug: pandas-dev/pandas#41408, pandas-dev/pandas#17869, pandas-dev/pandas#42471
robertwb added a commit to robertwb/incubator-beam that referenced this issue Aug 23, 2024
reeba212 pushed a commit to reeba212/beam that referenced this issue Dec 4, 2024
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
Projects
None yet
Development

No branches or pull requests

4 participants