@@ -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
@@ -1439,6 +1455,26 @@ def relabel_result(
1439
1455
return reordered_result_in_dict
1440
1456
1441
1457
1458
+ def reconstruct_and_relabel_result (result , func , ** kwargs ) -> DataFrame | Series :
1459
+ from pandas import DataFrame
1460
+
1461
+ relabeling , func , columns , order = reconstruct_func (func , ** kwargs )
1462
+
1463
+ if relabeling :
1464
+ # This is to keep the order to columns occurrence unchanged, and also
1465
+ # keep the order of new columns occurrence unchanged
1466
+
1467
+ # For the return values of reconstruct_func, if relabeling is
1468
+ # False, columns and order will be None.
1469
+ assert columns is not None
1470
+ assert order is not None
1471
+
1472
+ result_in_dict = relabel_result (result , func , columns , order )
1473
+ result = DataFrame (result_in_dict , index = columns )
1474
+
1475
+ return result
1476
+
1477
+
1442
1478
# TODO: Can't use, because mypy doesn't like us setting __name__
1443
1479
# error: "partial[Any]" has no attribute "__name__"
1444
1480
# the type is:
0 commit comments