Skip to content

Commit b78e379

Browse files
pckSFJulianWgs
authored andcommitted
TYP: Overload series/ffill and bfill (pandas-dev#41152)
* TYP: Overload series/ffill and bfill * Resolved comments * Keep the return types
1 parent 6e42bab commit b78e379

File tree

1 file changed

+84
-4
lines changed

1 file changed

+84
-4
lines changed

pandas/core/generic.py

+84-4
Original file line numberDiff line numberDiff line change
@@ -6474,13 +6474,53 @@ def fillna(
64746474
else:
64756475
return result.__finalize__(self, method="fillna")
64766476

6477+
@overload
6478+
def ffill(
6479+
self: FrameOrSeries,
6480+
axis: None | Axis = ...,
6481+
inplace: Literal[False] = ...,
6482+
limit: None | int = ...,
6483+
downcast=...,
6484+
) -> FrameOrSeries:
6485+
...
6486+
6487+
@overload
6488+
def ffill(
6489+
self: FrameOrSeries,
6490+
axis: None | Axis,
6491+
inplace: Literal[True],
6492+
limit: None | int = ...,
6493+
downcast=...,
6494+
) -> None:
6495+
...
6496+
6497+
@overload
6498+
def ffill(
6499+
self: FrameOrSeries,
6500+
*,
6501+
inplace: Literal[True],
6502+
limit: None | int = ...,
6503+
downcast=...,
6504+
) -> None:
6505+
...
6506+
6507+
@overload
6508+
def ffill(
6509+
self: FrameOrSeries,
6510+
axis: None | Axis = ...,
6511+
inplace: bool_t = ...,
6512+
limit: None | int = ...,
6513+
downcast=...,
6514+
) -> FrameOrSeries | None:
6515+
...
6516+
64776517
@final
64786518
@doc(klass=_shared_doc_kwargs["klass"])
64796519
def ffill(
64806520
self: FrameOrSeries,
6481-
axis=None,
6521+
axis: None | Axis = None,
64826522
inplace: bool_t = False,
6483-
limit=None,
6523+
limit: None | int = None,
64846524
downcast=None,
64856525
) -> FrameOrSeries | None:
64866526
"""
@@ -6497,13 +6537,53 @@ def ffill(
64976537

64986538
pad = ffill
64996539

6540+
@overload
6541+
def bfill(
6542+
self: FrameOrSeries,
6543+
axis: None | Axis = ...,
6544+
inplace: Literal[False] = ...,
6545+
limit: None | int = ...,
6546+
downcast=...,
6547+
) -> FrameOrSeries:
6548+
...
6549+
6550+
@overload
6551+
def bfill(
6552+
self: FrameOrSeries,
6553+
axis: None | Axis,
6554+
inplace: Literal[True],
6555+
limit: None | int = ...,
6556+
downcast=...,
6557+
) -> None:
6558+
...
6559+
6560+
@overload
6561+
def bfill(
6562+
self: FrameOrSeries,
6563+
*,
6564+
inplace: Literal[True],
6565+
limit: None | int = ...,
6566+
downcast=...,
6567+
) -> None:
6568+
...
6569+
6570+
@overload
6571+
def bfill(
6572+
self: FrameOrSeries,
6573+
axis: None | Axis = ...,
6574+
inplace: bool_t = ...,
6575+
limit: None | int = ...,
6576+
downcast=...,
6577+
) -> FrameOrSeries | None:
6578+
...
6579+
65006580
@final
65016581
@doc(klass=_shared_doc_kwargs["klass"])
65026582
def bfill(
65036583
self: FrameOrSeries,
6504-
axis=None,
6584+
axis: None | Axis = None,
65056585
inplace: bool_t = False,
6506-
limit=None,
6586+
limit: None | int = None,
65076587
downcast=None,
65086588
) -> FrameOrSeries | None:
65096589
"""

0 commit comments

Comments
 (0)