Skip to content

Commit b72519e

Browse files
gfyoungjreback
authored andcommitted
TST: Add test for groupby sum of large ints (#16671)
Closes gh-14758.
1 parent 0281886 commit b72519e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

pandas/tests/groupby/test_aggregate.py

+17
Original file line numberDiff line numberDiff line change
@@ -865,3 +865,20 @@ def test_agg_timezone_round_trip(self):
865865
ts = df['B'].iloc[2]
866866
assert ts == grouped.last()['B'].iloc[0]
867867
assert ts == grouped.apply(lambda x: x.iloc[-1])[0]
868+
869+
def test_sum_uint64_overflow(self):
870+
# see gh-14758
871+
872+
# Convert to uint64 and don't overflow
873+
df = pd.DataFrame([[1, 2], [3, 4], [5, 6]],
874+
dtype=object) + 9223372036854775807
875+
876+
index = pd.Index([9223372036854775808, 9223372036854775810,
877+
9223372036854775812], dtype=np.uint64)
878+
expected = pd.DataFrame({1: [9223372036854775809,
879+
9223372036854775811,
880+
9223372036854775813]}, index=index)
881+
882+
expected.index.name = 0
883+
result = df.groupby(0).sum()
884+
tm.assert_frame_equal(result, expected)

0 commit comments

Comments
 (0)