@@ -1148,11 +1148,7 @@ def _apply(
11481148 subset = slice (None ) if subset is None else subset
11491149 subset = non_reducing_slice (subset )
11501150 data = self .data .loc [subset ]
1151- if axis in [0 , "index" ]:
1152- result = data .apply (func , axis = 0 , ** kwargs )
1153- elif axis in [1 , "columns" ]:
1154- result = data .T .apply (func , axis = 0 , ** kwargs ).T # see GH 42005
1155- else :
1151+ if axis is None :
11561152 result = func (data , ** kwargs )
11571153 if not isinstance (result , DataFrame ):
11581154 if not isinstance (result , np .ndarray ):
@@ -1167,6 +1163,12 @@ def _apply(
11671163 f"Expected shape: { data .shape } "
11681164 )
11691165 result = DataFrame (result , index = data .index , columns = data .columns )
1166+ else :
1167+ axis = self .data ._get_axis_number (axis )
1168+ if axis == 0 :
1169+ result = data .apply (func , axis = 0 , ** kwargs )
1170+ else :
1171+ result = data .T .apply (func , axis = 0 , ** kwargs ).T # see GH 42005
11701172
11711173 if isinstance (result , Series ):
11721174 raise ValueError (
0 commit comments