Skip to content

BUG: read_json returns wrong value for big integer #33766

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

Closed
2 tasks done
mle-els opened this issue Apr 24, 2020 · 1 comment
Closed
2 tasks done

BUG: read_json returns wrong value for big integer #33766

mle-els opened this issue Apr 24, 2020 · 1 comment
Labels
Bug Duplicate Report Duplicate issue or pull request IO JSON read_json, to_json, json_normalize

Comments

@mle-els
Copy link

mle-els commented Apr 24, 2020

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.


Code Sample, a copy-pastable example

$ cat first-line.json
{"col":"72057594038135102"}
>>> pd.read_json("first-line.json", lines=True)
                 col
0  72057594038135104
>>> pd.read_json("first-line.json", lines=True, dtype=False)
                 col
0  72057594038135102

Problem description

pd.read_json() silently returns a wrong value when reading a big integer. This creates a problem when the integers are used as unique IDs.

Expected Output

Output of pd.show_versions()

INSTALLED VERSIONS

commit : None
python : 3.7.7.final.0
python-bits : 64
OS : Darwin
OS-release : 17.7.0
machine : x86_64
processor : i386
byteorder : little
LC_ALL : en_US.UTF-8
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 1.0.3
numpy : 1.18.3
pytz : 2019.3
dateutil : 2.8.1
pip : 20.0.2
setuptools : 46.0.0
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : 7.13.0
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pytest : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
xlsxwriter : None
numba : None

@mle-els mle-els added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Apr 24, 2020
@jschendel
Copy link
Member

This is a duplicate of #20608 and is caused by an intermediate conversion to float:

In [1]: int(float(72057594038135102))
Out[1]: 72057594038135104

@jschendel jschendel added Duplicate Report Duplicate issue or pull request IO JSON read_json, to_json, json_normalize and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Apr 24, 2020
@jschendel jschendel added this to the No action milestone Apr 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Duplicate Report Duplicate issue or pull request IO JSON read_json, to_json, json_normalize
Projects
None yet
Development

No branches or pull requests

2 participants