Skip to content

Commit

Permalink
TST: Add test for groupby sum of large ints
Browse files Browse the repository at this point in the history
Closes gh-14758.
  • Loading branch information
gfyoung committed Jun 11, 2017
1 parent d915c7e commit 309ecac
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions pandas/tests/groupby/test_aggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -865,3 +865,35 @@ 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
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)

# Remain as object
df = pd.DataFrame([[1, 2], [3, 4], [5, 6]],
dtype=object) + 19223372036854775807

index = pd.Index([19223372036854775808, 19223372036854775810,
19223372036854775812], dtype=object)
expected = pd.DataFrame({1: [19223372036854775809,
19223372036854775811,
19223372036854775813]},
dtype=object, index=index)

expected.index.name = 0
result = df.groupby(0).sum()
tm.assert_frame_equal(result, expected)

0 comments on commit 309ecac

Please sign in to comment.