Skip to content

Commit 934f4c0

Browse files
jorisvandenbosschemeeseeksmachine
authored andcommitted
Backport PR pandas-dev#54803: DOC: update docstrings for ffill and bfill (no longer aliases for fillna with method)
1 parent 72cb101 commit 934f4c0

File tree

1 file changed

+55
-5
lines changed

1 file changed

+55
-5
lines changed

pandas/core/generic.py

+55-5
Original file line numberDiff line numberDiff line change
@@ -7079,6 +7079,8 @@ def fillna(
70797079
70807080
See Also
70817081
--------
7082+
ffill : Fill values by propagating the last valid observation to next valid.
7083+
bfill : Fill values by using the next valid observation to fill the gap.
70827084
interpolate : Fill NaN values using interpolation.
70837085
reindex : Conform object to new index.
70847086
asfreq : Convert TimeSeries to specified frequency.
@@ -7338,7 +7340,10 @@ def ffill(
73387340
...
73397341

73407342
@final
7341-
@doc(klass=_shared_doc_kwargs["klass"])
7343+
@doc(
7344+
klass=_shared_doc_kwargs["klass"],
7345+
axes_single_arg=_shared_doc_kwargs["axes_single_arg"],
7346+
)
73427347
def ffill(
73437348
self,
73447349
*,
@@ -7350,6 +7355,27 @@ def ffill(
73507355
"""
73517356
Fill NA/NaN values by propagating the last valid observation to next valid.
73527357
7358+
Parameters
7359+
----------
7360+
axis : {axes_single_arg}
7361+
Axis along which to fill missing values. For `Series`
7362+
this parameter is unused and defaults to 0.
7363+
inplace : bool, default False
7364+
If True, fill in-place. Note: this will modify any
7365+
other views on this object (e.g., a no-copy slice for a column in a
7366+
DataFrame).
7367+
limit : int, default None
7368+
If method is specified, this is the maximum number of consecutive
7369+
NaN values to forward/backward fill. In other words, if there is
7370+
a gap with more than this number of consecutive NaNs, it will only
7371+
be partially filled. If method is not specified, this is the
7372+
maximum number of entries along the entire axis where NaNs will be
7373+
filled. Must be greater than 0 if not None.
7374+
downcast : dict, default is None
7375+
A dict of item->dtype of what to downcast if possible,
7376+
or the string 'infer' which will try to downcast to an appropriate
7377+
equal type (e.g. float64 to int64 if possible).
7378+
73537379
Returns
73547380
-------
73557381
{klass} or None
@@ -7417,7 +7443,7 @@ def pad(
74177443
downcast: dict | None | lib.NoDefault = lib.no_default,
74187444
) -> Self | None:
74197445
"""
7420-
Synonym for :meth:`DataFrame.fillna` with ``method='ffill'``.
7446+
Fill NA/NaN values by propagating the last valid observation to next valid.
74217447
74227448
.. deprecated:: 2.0
74237449
@@ -7474,7 +7500,10 @@ def bfill(
74747500
...
74757501

74767502
@final
7477-
@doc(klass=_shared_doc_kwargs["klass"])
7503+
@doc(
7504+
klass=_shared_doc_kwargs["klass"],
7505+
axes_single_arg=_shared_doc_kwargs["axes_single_arg"],
7506+
)
74787507
def bfill(
74797508
self,
74807509
*,
@@ -7484,7 +7513,28 @@ def bfill(
74847513
downcast: dict | None | lib.NoDefault = lib.no_default,
74857514
) -> Self | None:
74867515
"""
7487-
Synonym for :meth:`DataFrame.fillna` with ``method='bfill'``.
7516+
Fill NA/NaN values by using the next valid observation to fill the gap.
7517+
7518+
Parameters
7519+
----------
7520+
axis : {axes_single_arg}
7521+
Axis along which to fill missing values. For `Series`
7522+
this parameter is unused and defaults to 0.
7523+
inplace : bool, default False
7524+
If True, fill in-place. Note: this will modify any
7525+
other views on this object (e.g., a no-copy slice for a column in a
7526+
DataFrame).
7527+
limit : int, default None
7528+
If method is specified, this is the maximum number of consecutive
7529+
NaN values to forward/backward fill. In other words, if there is
7530+
a gap with more than this number of consecutive NaNs, it will only
7531+
be partially filled. If method is not specified, this is the
7532+
maximum number of entries along the entire axis where NaNs will be
7533+
filled. Must be greater than 0 if not None.
7534+
downcast : dict, default is None
7535+
A dict of item->dtype of what to downcast if possible,
7536+
or the string 'infer' which will try to downcast to an appropriate
7537+
equal type (e.g. float64 to int64 if possible).
74887538
74897539
Returns
74907540
-------
@@ -7563,7 +7613,7 @@ def backfill(
75637613
downcast: dict | None | lib.NoDefault = lib.no_default,
75647614
) -> Self | None:
75657615
"""
7566-
Synonym for :meth:`DataFrame.fillna` with ``method='bfill'``.
7616+
Fill NA/NaN values by using the next valid observation to fill the gap.
75677617
75687618
.. deprecated:: 2.0
75697619

0 commit comments

Comments
 (0)