@@ -59,6 +59,8 @@ from pandas._typing import (
59
59
Axes ,
60
60
Axis ,
61
61
AxisType ,
62
+ AxisTypeColumn ,
63
+ AxisTypeIndex ,
62
64
CalculationMethod ,
63
65
ColspaceArgType ,
64
66
CompressionOptions ,
@@ -1087,11 +1089,13 @@ class DataFrame(NDFrame, OpsMixin):
1087
1089
* args ,
1088
1090
** kwargs ,
1089
1091
) -> DataFrame : ...
1092
+
1093
+ # First set of apply is with defaults, and also with keyword result_type
1090
1094
@overload
1091
1095
def apply (
1092
1096
self ,
1093
1097
f : Callable [..., ListLikeExceptSeriesAndStr ],
1094
- axis : AxisType = ...,
1098
+ axis : AxisTypeIndex = ...,
1095
1099
raw : _bool = ...,
1096
1100
result_type : Literal [None ] = ...,
1097
1101
args = ...,
@@ -1101,7 +1105,7 @@ class DataFrame(NDFrame, OpsMixin):
1101
1105
def apply (
1102
1106
self ,
1103
1107
f : Callable [..., Series ],
1104
- axis : AxisType = ...,
1108
+ axis : AxisTypeIndex = ...,
1105
1109
raw : _bool = ...,
1106
1110
result_type : Literal [None ] = ...,
1107
1111
args = ...,
@@ -1111,7 +1115,7 @@ class DataFrame(NDFrame, OpsMixin):
1111
1115
def apply (
1112
1116
self ,
1113
1117
f : Callable [..., Scalar ],
1114
- axis : AxisType = ...,
1118
+ axis : AxisTypeIndex = ...,
1115
1119
raw : _bool = ...,
1116
1120
result_type : Literal [None ] = ...,
1117
1121
args = ...,
@@ -1121,7 +1125,7 @@ class DataFrame(NDFrame, OpsMixin):
1121
1125
def apply (
1122
1126
self ,
1123
1127
f : Callable [..., ListLikeExceptSeriesAndStr ],
1124
- axis : AxisType = ...,
1128
+ axis : AxisTypeIndex = ...,
1125
1129
raw : _bool = ...,
1126
1130
args = ...,
1127
1131
* ,
@@ -1132,7 +1136,7 @@ class DataFrame(NDFrame, OpsMixin):
1132
1136
def apply (
1133
1137
self ,
1134
1138
f : Callable [..., ListLikeExceptSeriesAndStr | Series ],
1135
- axis : AxisType = ...,
1139
+ axis : AxisTypeIndex = ...,
1136
1140
raw : _bool = ...,
1137
1141
args = ...,
1138
1142
* ,
@@ -1143,10 +1147,113 @@ class DataFrame(NDFrame, OpsMixin):
1143
1147
def apply (
1144
1148
self ,
1145
1149
f : Callable [..., ListLikeExceptSeriesAndStr | Series ],
1146
- axis : AxisType = ...,
1150
+ axis : AxisTypeIndex = ...,
1151
+ raw : _bool = ...,
1152
+ args = ...,
1153
+ * ,
1154
+ result_type : Literal ["broadcast" ],
1155
+ ** kwargs ,
1156
+ ) -> DataFrame : ...
1157
+
1158
+ # Second set of apply is with keyword axis=1 only
1159
+ @overload
1160
+ def apply (
1161
+ self ,
1162
+ f : Callable [..., ListLikeExceptSeriesAndStr ],
1163
+ raw : _bool = ...,
1164
+ result_type : Literal [None ] = ...,
1165
+ args = ...,
1166
+ * ,
1167
+ axis : AxisTypeColumn ,
1168
+ ** kwargs ,
1169
+ ) -> Series : ...
1170
+ @overload
1171
+ def apply (
1172
+ self ,
1173
+ f : Callable [..., Series ],
1174
+ raw : _bool = ...,
1175
+ result_type : Literal [None ] = ...,
1176
+ args = ...,
1177
+ * ,
1178
+ axis : AxisTypeColumn ,
1179
+ ** kwargs ,
1180
+ ) -> DataFrame : ...
1181
+ @overload
1182
+ def apply (
1183
+ self ,
1184
+ f : Callable [..., Scalar ],
1185
+ raw : _bool = ...,
1186
+ result_type : Literal [None ] = ...,
1187
+ args = ...,
1188
+ * ,
1189
+ axis : AxisTypeColumn ,
1190
+ ** kwargs ,
1191
+ ) -> Series : ...
1192
+
1193
+ # Third set of apply is with keyword axis=1 and keyword result_type
1194
+ @overload
1195
+ def apply (
1196
+ self ,
1197
+ f : Callable [..., ListLikeExceptSeriesAndStr ],
1198
+ raw : _bool = ...,
1199
+ args = ...,
1200
+ * ,
1201
+ axis : AxisTypeColumn = ...,
1202
+ result_type : Literal [None ] = ...,
1203
+ ** kwargs ,
1204
+ ) -> Series : ...
1205
+ @overload
1206
+ def apply (
1207
+ self ,
1208
+ f : Callable [..., Series ],
1209
+ raw : _bool = ...,
1210
+ args = ...,
1211
+ * ,
1212
+ axis : AxisTypeColumn = ...,
1213
+ result_type : Literal [None ] = ...,
1214
+ ** kwargs ,
1215
+ ) -> DataFrame : ...
1216
+ @overload
1217
+ def apply (
1218
+ self ,
1219
+ f : Callable [..., Scalar ],
1220
+ raw : _bool = ...,
1221
+ args = ...,
1222
+ * ,
1223
+ axis : AxisTypeColumn = ...,
1224
+ result_type : Literal [None ] = ...,
1225
+ ** kwargs ,
1226
+ ) -> Series : ...
1227
+ @overload
1228
+ def apply (
1229
+ self ,
1230
+ f : Callable [..., ListLikeExceptSeriesAndStr ],
1231
+ raw : _bool = ...,
1232
+ args = ...,
1233
+ * ,
1234
+ axis : AxisTypeColumn = ...,
1235
+ result_type : Literal ["reduce" ],
1236
+ ** kwargs ,
1237
+ ) -> Series : ...
1238
+ @overload
1239
+ def apply (
1240
+ self ,
1241
+ f : Callable [..., ListLikeExceptSeriesAndStr | Series ],
1242
+ raw : _bool = ...,
1243
+ args = ...,
1244
+ * ,
1245
+ axis : AxisTypeColumn = ...,
1246
+ result_type : Literal ["expand" ],
1247
+ ** kwargs ,
1248
+ ) -> DataFrame : ...
1249
+ @overload
1250
+ def apply (
1251
+ self ,
1252
+ f : Callable [..., ListLikeExceptSeriesAndStr | Series ],
1147
1253
raw : _bool = ...,
1148
1254
args = ...,
1149
1255
* ,
1256
+ axis : AxisTypeColumn = ...,
1150
1257
result_type : Literal ["broadcast" ],
1151
1258
** kwargs ,
1152
1259
) -> DataFrame : ...
0 commit comments