-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
OverflowError for string of large numbers (int64) while reading json #18842
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
Comments
It looks like previous versions would automatically convert that large number to a float, but you're getting an overflow error in 0.21.1 because it is attempting to fit that number into an int. FWIW you can work around this by explicitly specifying the dtype:
|
I believe the difference here was introduced in 4fd104a at the line below. Previously this was using a bare except that would catch everything, but now that the exception is more explicit that OverFlow error is not being caught and instead is sent further up the stack. I can take a go at this in a PR Line 684 in 4fd104a
|
I am experiencing the same error when reading a huge compressed json file. ~/anaconda3/lib/python3.6/site-packages/pandas/io/json/json.py in next(self) ~/anaconda3/lib/python3.6/site-packages/pandas/io/json/json.py in _get_object_parser(self, json) ~/anaconda3/lib/python3.6/site-packages/pandas/io/json/json.py in parse(self) ~/anaconda3/lib/python3.6/site-packages/pandas/io/json/json.py in _try_convert_types(self) ~/anaconda3/lib/python3.6/site-packages/pandas/io/json/json.py in _process_converter(self, f, filt) ~/anaconda3/lib/python3.6/site-packages/pandas/io/json/json.py in (col, c) ~/anaconda3/lib/python3.6/site-packages/pandas/io/json/json.py in _try_convert_data(self, name, data, use_dtypes, convert_dates) ~/anaconda3/lib/python3.6/site-packages/pandas/util/_decorators.py in wrapper(*args, **kwargs) ~/anaconda3/lib/python3.6/site-packages/pandas/core/generic.py in astype(self, dtype, copy, errors, **kwargs) ~/anaconda3/lib/python3.6/site-packages/pandas/core/internals.py in astype(self, dtype, **kwargs) ~/anaconda3/lib/python3.6/site-packages/pandas/core/internals.py in apply(self, f, axes, filter, do_integrity_check, consolidate, **kwargs) ~/anaconda3/lib/python3.6/site-packages/pandas/core/internals.py in astype(self, dtype, copy, errors, values, **kwargs) ~/anaconda3/lib/python3.6/site-packages/pandas/core/internals.py in _astype(self, dtype, copy, errors, values, klass, mgr, **kwargs) ~/anaconda3/lib/python3.6/site-packages/pandas/core/dtypes/cast.py in astype_nansafe(arr, dtype, copy) pandas/_libs/lib.pyx in pandas._libs.lib.astype_intsafe() pandas/_libs/src/util.pxd in util.set_value_at_unsafe() OverflowError: Python int too large to convert to C long |
I tried the work around, but didn't have success.
|
I avoided this error passing dtype=False |
Thanks, man you saved my time |
Reading json containing stringified numbers larger than int64 causes OverflowError in pandas 0.21.1. Appears to be working fine in 0.21.0
Max
The text was updated successfully, but these errors were encountered: