@@ -844,3 +844,33 @@ def test_agg_timezone_round_trip(self):
844
844
ts = df ['B' ].iloc [2 ]
845
845
assert ts == grouped .last ()['B' ].iloc [0 ]
846
846
assert ts == grouped .apply (lambda x : x .iloc [- 1 ])[0 ]
847
+
848
+ def test_sum_uint64_overflow (self ):
849
+ # see gh-14758
850
+
851
+ # Convert to uint64
852
+ df = pd .DataFrame ([[1 , 2 ], [3 , 4 ], [5 , 6 ]],
853
+ dtype = object ) + 9223372036854775807
854
+
855
+ index = pd .Index ([9223372036854775808 , 9223372036854775810 ,
856
+ 9223372036854775812 ], dtype = np .uint64 )
857
+ expected = pd .DataFrame ({1 : [9223372036854775809 ,
858
+ 9223372036854775811 ,
859
+ 9223372036854775813 ]}, index = index )
860
+
861
+ expected .index .name = 0
862
+ result = df .groupby (0 ).sum ()
863
+ tm .assert_frame_equal (result , expected )
864
+
865
+ # Remain as object
866
+ df = pd .DataFrame ([[1 , 2 ], [3 , 4 ], [5 , 6 ]],
867
+ dtype = object ) + 19223372036854775807
868
+
869
+ index = pd .Index ([19223372036854775808 , 19223372036854775810 ,
870
+ 19223372036854775812 ], dtype = object )
871
+ expected = pd .DataFrame ({1 : [19223372036854775809 ,
872
+ 19223372036854775811 ,
873
+ 19223372036854775813 ]}, index = index )
874
+ expected .index .name = 0
875
+ result = df .groupby (0 ).sum ()
876
+ tm .assert_frame_equal (result , expected )
0 commit comments