@@ -1148,11 +1148,7 @@ def _apply(
1148
1148
subset = slice (None ) if subset is None else subset
1149
1149
subset = non_reducing_slice (subset )
1150
1150
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 :
1156
1152
result = func (data , ** kwargs )
1157
1153
if not isinstance (result , DataFrame ):
1158
1154
if not isinstance (result , np .ndarray ):
@@ -1167,6 +1163,12 @@ def _apply(
1167
1163
f"Expected shape: { data .shape } "
1168
1164
)
1169
1165
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
1170
1172
1171
1173
if isinstance (result , Series ):
1172
1174
raise ValueError (
0 commit comments