File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
pandas/tests/groupby/aggregate Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -1377,6 +1377,43 @@ def func(ser):
1377
1377
tm .assert_frame_equal (res , expected )
1378
1378
1379
1379
1380
+ @pytest .mark .parametrize (
1381
+ "dtype" ,
1382
+ [
1383
+ "int64" ,
1384
+ "uint64" ,
1385
+ "int32" ,
1386
+ "uint32" ,
1387
+ "float64" ,
1388
+ "float32" ,
1389
+ "Int64" ,
1390
+ "UInt64" ,
1391
+ "Int32" ,
1392
+ "UInt32" ,
1393
+ "Float64" ,
1394
+ "Float32" ,
1395
+ ],
1396
+ )
1397
+ def test_groupby_agg_precision (dtype ):
1398
+ # GH33234
1399
+ df = DataFrame (
1400
+ {
1401
+ "key1" : ["a" ],
1402
+ "key2" : ["b" ],
1403
+ "key3" : [
1404
+ pd .array ([1583715738627261039 ], dtype = dtype )[0 ]
1405
+ if dtype not in ["int32" , "uint32" , "Int32" , "UInt32" ]
1406
+ else pd .array ([4294967295 ], dtype = dtype )[0 ]
1407
+ if dtype in ["uint32" , "UInt32" ]
1408
+ else pd .array ([2147483647 ], dtype = dtype )[0 ]
1409
+ ],
1410
+ }
1411
+ )
1412
+ expected = df [["key3" ]]
1413
+ result = df .groupby (["key1" , "key2" ]).agg (lambda x : x ).reset_index ()[["key3" ]]
1414
+ tm .assert_frame_equal (result , expected )
1415
+
1416
+
1380
1417
def test_groupby_aggregate_directory (reduction_func ):
1381
1418
# GH#32793
1382
1419
if reduction_func in ["corrwith" , "nth" ]:
You can’t perform that action at this time.
0 commit comments