Skip to content

pandas/tests/io/json/test_pandas.py::TestPandasContainer::test_read_json_large_numbers failing for 32-bit system #35279

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

Open
TomAugspurger opened this issue Jul 15, 2020 · 1 comment
Labels
32bit 32-bit systems Bug IO JSON read_json, to_json, json_normalize

Comments

@TomAugspurger
Copy link
Contributor

    @pytest.mark.parametrize("bigNum", [sys.maxsize + 1, -(sys.maxsize + 2)])
    # @pytest.mark.xfail(sys.maxsize == 2**32, reason="")
    def test_read_json_large_numbers(self, bigNum):
        # GH20599

        series = Series(bigNum, dtype=object, index=["articleId"])
        json = '{"articleId":' + str(bigNum) + "}"
        with pytest.raises(ValueError):
            json = StringIO(json)
            result = read_json(json)
            tm.assert_series_equal(series, result)

        df = DataFrame(bigNum, dtype=object, index=["articleId"], columns=[0])
        json = '{"0":{"articleId":' + str(bigNum) + "}}"
        with pytest.raises(ValueError):
            json = StringIO(json)
            result = read_json(json)
>           tm.assert_frame_equal(df, result)
E           AssertionError: Attributes of DataFrame.iloc[:, 0] (column name="0") are different
E
E           Attribute "dtype" are different
E           [left]:  object
E           [right]: int64

We have

-> tm.assert_frame_equal(df, result)
(Pdb) result
           0
articleId  1
(Pdb) df
                              0
articleId  18446744073709551617
@TomAugspurger TomAugspurger added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Jul 15, 2020
@TomAugspurger
Copy link
Contributor Author

I think there are two issues:

  1. For numbers between 32-bit and 64-bit max, the result is correct but the test is wrong. On 32-bit systems the result is int64 dtype.
  2. For numbers larger than 64-bit max, the result wraps around.

@TomAugspurger TomAugspurger added 32bit 32-bit systems IO JSON read_json, to_json, json_normalize and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Jul 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
32bit 32-bit systems Bug IO JSON read_json, to_json, json_normalize
Projects
None yet
Development

No branches or pull requests

1 participant