Skip to content

Commit

Permalink
DOC: update the Index.shift docstring (#20192)
Browse files Browse the repository at this point in the history
* DOC: updating docstring of Index.shift

* Add See Also section to shift

* Update link to Series.shift
  • Loading branch information
DataOmbudsman authored and TomAugspurger committed Mar 10, 2018
1 parent 5b0caf4 commit dd7f567
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -2276,6 +2277,10 @@ def shift(self, periods=1, freq=None):
pandas.Index
shifted index
See Also
--------
Series.shift : Shift values of Series.
Examples
--------
Put the first 5 month starts of 2011 into an index.
Expand Down

0 comments on commit dd7f567

Please sign in to comment.