@@ -1377,6 +1377,42 @@ def func(ser):
1377
1377
tm .assert_frame_equal (res , expected )
1378
1378
1379
1379
1380
+ def test_groupby_agg_precision (any_real_numeric_dtype ):
1381
+ # GH33234
1382
+ if any_real_numeric_dtype in ["int8" , "Int8" ]:
1383
+ max_value = 127
1384
+ elif any_real_numeric_dtype in ["uint8" , "UInt8" ]:
1385
+ max_value = 255
1386
+ elif any_real_numeric_dtype in ["int16" , "Int16" ]:
1387
+ max_value = 32767
1388
+ elif any_real_numeric_dtype in ["uint16" , "UInt16" ]:
1389
+ max_value = 65535
1390
+ elif any_real_numeric_dtype in ["int32" , "Int32" ]:
1391
+ max_value = 2147483647
1392
+ elif any_real_numeric_dtype in ["uint32" , "UInt32" , "float32" , "Float32" ]:
1393
+ max_value = 4294967295
1394
+ elif any_real_numeric_dtype in ["uint64" , "UInt64" , "float64" , "Float64" ]:
1395
+ max_value = 18446744073709551615
1396
+ else :
1397
+ max_value = 9223372036854775807
1398
+
1399
+ df = DataFrame (
1400
+ {
1401
+ "key1" : ["a" ],
1402
+ "key2" : ["b" ],
1403
+ "key3" : pd .array ([max_value ], dtype = any_real_numeric_dtype ),
1404
+ }
1405
+ )
1406
+ arrays = [["a" ], ["b" ]]
1407
+ index = MultiIndex .from_arrays (arrays , names = ("key1" , "key2" ))
1408
+
1409
+ expected = DataFrame (
1410
+ {"key3" : pd .array ([max_value ], dtype = any_real_numeric_dtype )}, index = index
1411
+ )
1412
+ result = df .groupby (["key1" , "key2" ]).agg (lambda x : x )
1413
+ tm .assert_frame_equal (result , expected )
1414
+
1415
+
1380
1416
def test_groupby_aggregate_directory (reduction_func ):
1381
1417
# GH#32793
1382
1418
if reduction_func in ["corrwith" , "nth" ]:
0 commit comments