From 46fa00fb7af883919e0a32b019f03dc6ba4c0769 Mon Sep 17 00:00:00 2001 From: Patrick Hoefler Date: Sat, 17 Sep 2022 12:05:14 +0200 Subject: [PATCH 1/3] DOC: Add deprecation infos to deprecated functions --- pandas/core/groupby/groupby.py | 16 ++++++++++++---- pandas/core/indexes/base.py | 4 ++++ pandas/core/indexes/interval.py | 2 ++ pandas/core/resample.py | 16 ++++++++++++---- 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index 6d9ef3c484971..409a01ca189a9 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -2938,6 +2938,12 @@ def ffill(self, limit=None): return self._fill("ffill", limit=limit) def pad(self, limit=None): + """ + Forward fill the values. + + .. deprecated:: 1.4 + Use ffill instead. + """ warnings.warn( "pad is deprecated and will be removed in a future version. " "Use ffill instead.", @@ -2946,8 +2952,6 @@ def pad(self, limit=None): ) return self.ffill(limit=limit) - pad.__doc__ = ffill.__doc__ - @final @Substitution(name="groupby") def bfill(self, limit=None): @@ -2974,6 +2978,12 @@ def bfill(self, limit=None): return self._fill("bfill", limit=limit) def backfill(self, limit=None): + """ + Backward fill the values. + + .. deprecated:: 1.4 + Use bfill instead. + """ warnings.warn( "backfill is deprecated and will be removed in a future version. " "Use bfill instead.", @@ -2982,8 +2992,6 @@ def backfill(self, limit=None): ) return self.bfill(limit=limit) - backfill.__doc__ = bfill.__doc__ - @final @Substitution(name="groupby") @Substitution(see_also=_common_see_also) diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 52150eafd7783..32a959ed1baee 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -3773,6 +3773,10 @@ def get_loc(self, key, method=None, tolerance=None): * backfill / bfill: use NEXT index value if no exact match * nearest: use the NEAREST index value if no exact match. Tied distances are broken by preferring the larger index value. + + .. deprecated:: 1.4 + Use index.get_indexer([item], method=...) instead. + tolerance : int or float, optional Maximum distance from index value for inexact matches. The value of the index at the matching location must satisfy the equation diff --git a/pandas/core/indexes/interval.py b/pandas/core/indexes/interval.py index e686e8453f0d9..943077e575266 100644 --- a/pandas/core/indexes/interval.py +++ b/pandas/core/indexes/interval.py @@ -592,6 +592,8 @@ def get_loc( method : {None}, optional * default: matches where the label is within an interval only. + .. deprecated:: 1.4 + Returns ------- int if unique index, slice if monotonic index, else mask diff --git a/pandas/core/resample.py b/pandas/core/resample.py index 85731bbde6d40..2fa93ad736187 100644 --- a/pandas/core/resample.py +++ b/pandas/core/resample.py @@ -546,6 +546,12 @@ def ffill(self, limit=None): return self._upsample("ffill", limit=limit) def pad(self, limit=None): + """ + Forward fill the values. + + .. deprecated:: 1.4 + Use ffill instead. + """ warnings.warn( "pad is deprecated and will be removed in a future version. " "Use ffill instead.", @@ -554,8 +560,6 @@ def pad(self, limit=None): ) return self.ffill(limit=limit) - pad.__doc__ = ffill.__doc__ - def nearest(self, limit=None): """ Resample by using the nearest value. @@ -719,6 +723,12 @@ def bfill(self, limit=None): return self._upsample("bfill", limit=limit) def backfill(self, limit=None): + """ + Backward fill the values. + + .. deprecated:: 1.4 + Use bfill instead. + """ warnings.warn( "backfill is deprecated and will be removed in a future version. " "Use bfill instead.", @@ -727,8 +737,6 @@ def backfill(self, limit=None): ) return self.bfill(limit=limit) - backfill.__doc__ = bfill.__doc__ - def fillna(self, method, limit=None): """ Fill missing values introduced by upsampling. From 112da04ad286fc06efb55f17fb789c05202e696c Mon Sep 17 00:00:00 2001 From: Patrick Hoefler Date: Mon, 19 Sep 2022 22:28:48 +0200 Subject: [PATCH 2/3] Add sections --- pandas/core/groupby/groupby.py | 21 +++++++++++++++++++++ pandas/core/resample.py | 19 +++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index 409a01ca189a9..40632da1d8644 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -2943,6 +2943,16 @@ def pad(self, limit=None): .. deprecated:: 1.4 Use ffill instead. + + Parameters + ---------- + limit : int, optional + Limit of how many values to fill. + + Returns + ------- + Series or DataFrame + Object with missing values filled. """ warnings.warn( "pad is deprecated and will be removed in a future version. " @@ -2983,6 +2993,17 @@ def backfill(self, limit=None): .. deprecated:: 1.4 Use bfill instead. + + Parameters + ---------- + limit : int, optional + Limit of how many values to fill. + + Returns + ------- + Series or DataFrame + Object with missing values filled. + """ warnings.warn( "backfill is deprecated and will be removed in a future version. " diff --git a/pandas/core/resample.py b/pandas/core/resample.py index 2fa93ad736187..82340849164a8 100644 --- a/pandas/core/resample.py +++ b/pandas/core/resample.py @@ -551,6 +551,15 @@ def pad(self, limit=None): .. deprecated:: 1.4 Use ffill instead. + + Parameters + ---------- + limit : int, optional + Limit of how many values to fill. + + Returns + ------- + An upsampled Series. """ warnings.warn( "pad is deprecated and will be removed in a future version. " @@ -728,6 +737,16 @@ def backfill(self, limit=None): .. deprecated:: 1.4 Use bfill instead. + + Parameters + ---------- + limit : int, optional + Limit of how many values to fill. + + Returns + ------- + Series, DataFrame + An upsampled Series or DataFrame with backward filled NaN values. """ warnings.warn( "backfill is deprecated and will be removed in a future version. " From ea806dd9422c46d8cedd332b135c30ee03a530c6 Mon Sep 17 00:00:00 2001 From: Patrick Hoefler Date: Mon, 19 Sep 2022 23:50:49 +0200 Subject: [PATCH 3/3] Fix --- pandas/core/groupby/groupby.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index 40632da1d8644..9204b728dfa51 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -3003,7 +3003,6 @@ def backfill(self, limit=None): ------- Series or DataFrame Object with missing values filled. - """ warnings.warn( "backfill is deprecated and will be removed in a future version. "