Skip to content

Commit 54da73d

Browse files
jorisvandenbosschemroeschke
authored andcommitted
DOC: update docstrings for ffill and bfill (no longer aliases for fillna with method) (pandas-dev#54803)
1 parent fff5814 commit 54da73d

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
@@ -7099,6 +7099,8 @@ def fillna(
70997099
71007100
See Also
71017101
--------
7102+
ffill : Fill values by propagating the last valid observation to next valid.
7103+
bfill : Fill values by using the next valid observation to fill the gap.
71027104
interpolate : Fill NaN values using interpolation.
71037105
reindex : Conform object to new index.
71047106
asfreq : Convert TimeSeries to specified frequency.
@@ -7358,7 +7360,10 @@ def ffill(
73587360
...
73597361

73607362
@final
7361-
@doc(klass=_shared_doc_kwargs["klass"])
7363+
@doc(
7364+
klass=_shared_doc_kwargs["klass"],
7365+
axes_single_arg=_shared_doc_kwargs["axes_single_arg"],
7366+
)
73627367
def ffill(
73637368
self,
73647369
*,
@@ -7370,6 +7375,27 @@ def ffill(
73707375
"""
73717376
Fill NA/NaN values by propagating the last valid observation to next valid.
73727377
7378+
Parameters
7379+
----------
7380+
axis : {axes_single_arg}
7381+
Axis along which to fill missing values. For `Series`
7382+
this parameter is unused and defaults to 0.
7383+
inplace : bool, default False
7384+
If True, fill in-place. Note: this will modify any
7385+
other views on this object (e.g., a no-copy slice for a column in a
7386+
DataFrame).
7387+
limit : int, default None
7388+
If method is specified, this is the maximum number of consecutive
7389+
NaN values to forward/backward fill. In other words, if there is
7390+
a gap with more than this number of consecutive NaNs, it will only
7391+
be partially filled. If method is not specified, this is the
7392+
maximum number of entries along the entire axis where NaNs will be
7393+
filled. Must be greater than 0 if not None.
7394+
downcast : dict, default is None
7395+
A dict of item->dtype of what to downcast if possible,
7396+
or the string 'infer' which will try to downcast to an appropriate
7397+
equal type (e.g. float64 to int64 if possible).
7398+
73737399
Returns
73747400
-------
73757401
{klass} or None
@@ -7437,7 +7463,7 @@ def pad(
74377463
downcast: dict | None | lib.NoDefault = lib.no_default,
74387464
) -> Self | None:
74397465
"""
7440-
Synonym for :meth:`DataFrame.fillna` with ``method='ffill'``.
7466+
Fill NA/NaN values by propagating the last valid observation to next valid.
74417467
74427468
.. deprecated:: 2.0
74437469
@@ -7494,7 +7520,10 @@ def bfill(
74947520
...
74957521

74967522
@final
7497-
@doc(klass=_shared_doc_kwargs["klass"])
7523+
@doc(
7524+
klass=_shared_doc_kwargs["klass"],
7525+
axes_single_arg=_shared_doc_kwargs["axes_single_arg"],
7526+
)
74987527
def bfill(
74997528
self,
75007529
*,
@@ -7504,7 +7533,28 @@ def bfill(
75047533
downcast: dict | None | lib.NoDefault = lib.no_default,
75057534
) -> Self | None:
75067535
"""
7507-
Synonym for :meth:`DataFrame.fillna` with ``method='bfill'``.
7536+
Fill NA/NaN values by using the next valid observation to fill the gap.
7537+
7538+
Parameters
7539+
----------
7540+
axis : {axes_single_arg}
7541+
Axis along which to fill missing values. For `Series`
7542+
this parameter is unused and defaults to 0.
7543+
inplace : bool, default False
7544+
If True, fill in-place. Note: this will modify any
7545+
other views on this object (e.g., a no-copy slice for a column in a
7546+
DataFrame).
7547+
limit : int, default None
7548+
If method is specified, this is the maximum number of consecutive
7549+
NaN values to forward/backward fill. In other words, if there is
7550+
a gap with more than this number of consecutive NaNs, it will only
7551+
be partially filled. If method is not specified, this is the
7552+
maximum number of entries along the entire axis where NaNs will be
7553+
filled. Must be greater than 0 if not None.
7554+
downcast : dict, default is None
7555+
A dict of item->dtype of what to downcast if possible,
7556+
or the string 'infer' which will try to downcast to an appropriate
7557+
equal type (e.g. float64 to int64 if possible).
75087558
75097559
Returns
75107560
-------
@@ -7583,7 +7633,7 @@ def backfill(
75837633
downcast: dict | None | lib.NoDefault = lib.no_default,
75847634
) -> Self | None:
75857635
"""
7586-
Synonym for :meth:`DataFrame.fillna` with ``method='bfill'``.
7636+
Fill NA/NaN values by using the next valid observation to fill the gap.
75877637
75887638
.. deprecated:: 2.0
75897639

0 commit comments

Comments
 (0)