From b72519e45bbfe7387e0c576c9315475aace69a2b Mon Sep 17 00:00:00 2001 From: gfyoung Date: Mon, 12 Jun 2017 05:46:52 -0500 Subject: [PATCH] TST: Add test for groupby sum of large ints (#16671) Closes gh-14758. --- pandas/tests/groupby/test_aggregate.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/pandas/tests/groupby/test_aggregate.py b/pandas/tests/groupby/test_aggregate.py index 0de263589c6d6..b578a6efb0034 100644 --- a/pandas/tests/groupby/test_aggregate.py +++ b/pandas/tests/groupby/test_aggregate.py @@ -865,3 +865,20 @@ def test_agg_timezone_round_trip(self): ts = df['B'].iloc[2] assert ts == grouped.last()['B'].iloc[0] assert ts == grouped.apply(lambda x: x.iloc[-1])[0] + + def test_sum_uint64_overflow(self): + # see gh-14758 + + # Convert to uint64 and don't overflow + df = pd.DataFrame([[1, 2], [3, 4], [5, 6]], + dtype=object) + 9223372036854775807 + + index = pd.Index([9223372036854775808, 9223372036854775810, + 9223372036854775812], dtype=np.uint64) + expected = pd.DataFrame({1: [9223372036854775809, + 9223372036854775811, + 9223372036854775813]}, index=index) + + expected.index.name = 0 + result = df.groupby(0).sum() + tm.assert_frame_equal(result, expected)