From a520a9394d494d9a3b0aa5052e9a1e5d439c4aed Mon Sep 17 00:00:00 2001 From: Arpad Fulop Date: Sat, 10 Mar 2018 16:52:38 +0100 Subject: [PATCH 1/3] DOC: updating docstring of Index.shift --- pandas/core/indexes/base.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 52283e4e223b4..b805d22085e14 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -2256,18 +2256,19 @@ def sortlevel(self, level=None, ascending=True, sort_remaining=None): return self.sort_values(return_indexer=True, ascending=ascending) def shift(self, periods=1, freq=None): - """Shift index by desired number of time frequency increments. + """ + Shift index by desired number of time frequency increments. This method is for shifting the values of datetime-like indexes by a specified time increment a given number of times. Parameters ---------- - periods : int + periods : int, default 1 Number of periods (or increments) to shift by, - can be positive or negative (default is 1). - freq : pandas.DateOffset, pandas.Timedelta or string - Frequency increment to shift by (default is None). + can be positive or negative. + freq : pandas.DateOffset, pandas.Timedelta or string, optional + Frequency increment to shift by. If None, the index is shifted by its own `freq` attribute. Offset aliases are valid strings, e.g., 'D', 'W', 'M' etc. From cafcf6330697b5355016209a4f57b8dc5f8d17c7 Mon Sep 17 00:00:00 2001 From: Arpad Fulop Date: Sat, 10 Mar 2018 19:22:06 +0100 Subject: [PATCH 2/3] Add See Also section to shift --- pandas/core/indexes/base.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index b805d22085e14..74676801a4f0d 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -2277,6 +2277,10 @@ def shift(self, periods=1, freq=None): pandas.Index shifted index + See Also + -------- + :meth:`Series.shift` : Shift values of Series. + Examples -------- Put the first 5 month starts of 2011 into an index. From 003cd14ae166fe19ae9ddd03bac2aa54c334f165 Mon Sep 17 00:00:00 2001 From: Arpad Fulop Date: Sat, 10 Mar 2018 19:33:01 +0100 Subject: [PATCH 3/3] Update link to Series.shift --- pandas/core/indexes/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 74676801a4f0d..3c357788c9d6b 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -2279,7 +2279,7 @@ def shift(self, periods=1, freq=None): See Also -------- - :meth:`Series.shift` : Shift values of Series. + Series.shift : Shift values of Series. Examples --------