@@ -1463,6 +1463,34 @@ def test_agg_cython_table_raises(self, df, func, expected, axis):
1463
1463
with pytest .raises (expected , match = msg ):
1464
1464
df .agg (func , axis = axis )
1465
1465
1466
+ @pytest .mark .parametrize ("axis" , [0 , 1 ])
1467
+ @pytest .mark .parametrize (
1468
+ "args, kwargs" ,
1469
+ [
1470
+ ((1 , 2 , 3 ), {}),
1471
+ ((8 , 7 , 15 ), {}),
1472
+ ((1 , 2 ), {}),
1473
+ ((1 ,), {"b" : 2 }),
1474
+ ((), {"a" : 1 , "b" : 2 }),
1475
+ ((), {"a" : 2 , "b" : 1 }),
1476
+ ((), {"a" : 1 , "b" : 2 , "c" : 3 }),
1477
+ ],
1478
+ )
1479
+ def test_agg_args_kwargs (self , axis , args , kwargs ):
1480
+ def f (x , a , b , c = 3 ):
1481
+ return x .sum () + (a + b ) / c
1482
+
1483
+ df = pd .DataFrame ([[1 , 2 ], [3 , 4 ]])
1484
+
1485
+ if axis == 0 :
1486
+ expected = pd .Series ([5.0 , 7.0 ])
1487
+ else :
1488
+ expected = pd .Series ([4.0 , 8.0 ])
1489
+
1490
+ result = df .agg (f , axis , * args , ** kwargs )
1491
+
1492
+ tm .assert_series_equal (result , expected )
1493
+
1466
1494
@pytest .mark .parametrize ("num_cols" , [2 , 3 , 5 ])
1467
1495
def test_frequency_is_original (self , num_cols ):
1468
1496
# GH 22150
0 commit comments