@@ -136,7 +136,6 @@ from pandas._typing import (
136
136
ScalarT ,
137
137
SequenceNotStr ,
138
138
SeriesByT ,
139
- SeriesDType ,
140
139
SortKind ,
141
140
StataDateFormat ,
142
141
StorageOptions ,
@@ -1392,23 +1391,13 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
1392
1391
@overload
1393
1392
def apply (
1394
1393
self ,
1395
- f : Callable [..., S2 ],
1394
+ f : Callable [..., S2 | NAType ],
1396
1395
axis : AxisIndex = ...,
1397
1396
raw : _bool = ...,
1398
1397
result_type : None = ...,
1399
1398
args : Any = ...,
1400
1399
** kwargs : Any ,
1401
1400
) -> Series [S2 ]: ...
1402
- @overload
1403
- def apply (
1404
- self ,
1405
- f : Callable [..., SeriesDType | NAType ],
1406
- axis : AxisIndex = ...,
1407
- raw : _bool = ...,
1408
- result_type : None = ...,
1409
- args : Any = ...,
1410
- ** kwargs : Any ,
1411
- ) -> Series : ...
1412
1401
# Since non-scalar type T is not supported in Series[T],
1413
1402
# we separate this overload from the above one
1414
1403
@overload
@@ -1426,7 +1415,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
1426
1415
@overload
1427
1416
def apply (
1428
1417
self ,
1429
- f : Callable [..., S2 ],
1418
+ f : Callable [..., S2 | NAType ],
1430
1419
axis : Axis = ...,
1431
1420
raw : _bool = ...,
1432
1421
args : Any = ...,
@@ -1435,17 +1424,6 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
1435
1424
** kwargs : Any ,
1436
1425
) -> Series [S2 ]: ...
1437
1426
@overload
1438
- def apply (
1439
- self ,
1440
- f : Callable [..., SeriesDType | NAType ],
1441
- axis : Axis = ...,
1442
- raw : _bool = ...,
1443
- args : Any = ...,
1444
- * ,
1445
- result_type : Literal ["expand" , "reduce" ],
1446
- ** kwargs : Any ,
1447
- ) -> Series : ...
1448
- @overload
1449
1427
def apply (
1450
1428
self ,
1451
1429
f : Callable [..., ListLikeExceptSeriesAndStr | Series | Mapping [Any , Any ]],
@@ -1495,11 +1473,10 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
1495
1473
) -> Series : ...
1496
1474
1497
1475
# apply() overloads with default result_type of None, and keyword axis=1 matters
1498
- # Use S2 (TypeVar without the `Any` default) to avoid MyPy issue https://github.com/python/mypy/issues/19182.
1499
1476
@overload
1500
1477
def apply (
1501
1478
self ,
1502
- f : Callable [..., S2 ],
1479
+ f : Callable [..., S2 | NAType ],
1503
1480
raw : _bool = ...,
1504
1481
result_type : None = ...,
1505
1482
args : Any = ...,
@@ -1508,17 +1485,6 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
1508
1485
** kwargs : Any ,
1509
1486
) -> Series [S2 ]: ...
1510
1487
@overload
1511
- def apply (
1512
- self ,
1513
- f : Callable [..., SeriesDType | NAType ],
1514
- raw : _bool = ...,
1515
- result_type : None = ...,
1516
- args : Any = ...,
1517
- * ,
1518
- axis : AxisColumn ,
1519
- ** kwargs : Any ,
1520
- ) -> Series : ...
1521
- @overload
1522
1488
def apply (
1523
1489
self ,
1524
1490
f : Callable [..., ListLikeExceptSeriesAndStr | Mapping [Any , Any ]],
0 commit comments