@@ -91,6 +91,9 @@ def frame_apply(
91
91
elif axis == 1 :
92
92
klass = FrameColumnApply
93
93
94
+ _ , func , _ , _ = reconstruct_func (func , ** kwargs )
95
+ assert func is not None
96
+
94
97
return klass (
95
98
obj ,
96
99
func ,
@@ -547,7 +550,20 @@ def apply_multiple(self) -> DataFrame | Series:
547
550
result: Series, DataFrame, or None
548
551
Result when self.f is a list-like or dict-like, None otherwise.
549
552
"""
550
- return self .obj .aggregate (self .f , self .axis , * self .args , ** self .kwargs )
553
+ if self .axis == 1 and isinstance (self .obj , ABCDataFrame ):
554
+ return self .obj .T .apply (self .f , 0 , args = self .args , ** self .kwargs ).T
555
+
556
+ func = self .f
557
+ kwargs = self .kwargs
558
+
559
+ if is_dict_like (func ):
560
+ result = self .agg_dict_like ()
561
+ else :
562
+ result = self .agg_list_like ()
563
+
564
+ result = reconstruct_and_relabel_result (result , func , ** kwargs )
565
+
566
+ return result
551
567
552
568
def normalize_dictlike_arg (
553
569
self , how : str , obj : DataFrame | Series , func : AggFuncTypeDict
@@ -1444,6 +1460,26 @@ def relabel_result(
1444
1460
return reordered_result_in_dict
1445
1461
1446
1462
1463
+ def reconstruct_and_relabel_result (result , func , ** kwargs ) -> DataFrame | Series :
1464
+ from pandas import DataFrame
1465
+
1466
+ relabeling , func , columns , order = reconstruct_func (func , ** kwargs )
1467
+
1468
+ if relabeling :
1469
+ # This is to keep the order to columns occurrence unchanged, and also
1470
+ # keep the order of new columns occurrence unchanged
1471
+
1472
+ # For the return values of reconstruct_func, if relabeling is
1473
+ # False, columns and order will be None.
1474
+ assert columns is not None
1475
+ assert order is not None
1476
+
1477
+ result_in_dict = relabel_result (result , func , columns , order )
1478
+ result = DataFrame (result_in_dict , index = columns )
1479
+
1480
+ return result
1481
+
1482
+
1447
1483
# TODO: Can't use, because mypy doesn't like us setting __name__
1448
1484
# error: "partial[Any]" has no attribute "__name__"
1449
1485
# the type is:
0 commit comments