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 @@ -1367,6 +1367,43 @@ def func(ser):
1367
1367
tm .assert_frame_equal (res , expected )
1368
1368
1369
1369
1370
+ @pytest .mark .parametrize (
1371
+ "dtype" ,
1372
+ [
1373
+ "int64" ,
1374
+ "uint64" ,
1375
+ "int32" ,
1376
+ "uint32" ,
1377
+ "float64" ,
1378
+ "float32" ,
1379
+ "Int64" ,
1380
+ "UInt64" ,
1381
+ "Int32" ,
1382
+ "UInt32" ,
1383
+ "Float64" ,
1384
+ "Float32" ,
1385
+ ],
1386
+ )
1387
+ def test_groupby_agg_precision (dtype ):
1388
+ # GH33234
1389
+ df = DataFrame (
1390
+ {
1391
+ "key1" : ["a" ],
1392
+ "key2" : ["b" ],
1393
+ "key3" : [
1394
+ 1583715738627261039
1395
+ if dtype not in ["int32" , "uint32" , "Int32" , "UInt32" ]
1396
+ else 4294967295
1397
+ if dtype in ["uint32" , "UInt32" ]
1398
+ else 2147483647
1399
+ ],
1400
+ }
1401
+ ).astype ({"key3" : dtype })
1402
+ expected = df [["key3" ]]
1403
+ result = df .groupby (["key1" , "key2" ]).agg (lambda x : x ).reset_index ()[["key3" ]]
1404
+ tm .assert_frame_equal (result , expected )
1405
+
1406
+
1370
1407
def test_groupby_aggregate_directory (reduction_func ):
1371
1408
# GH#32793
1372
1409
if reduction_func in ["corrwith" , "nth" ]:
You can’t perform that action at this time.
0 commit comments