shift(self, periods=1, freq=None)
This method is for shifting the values of datetime-like indexes by a specified time increment a given number of times.
This method is only implemented for datetime-like index classes, i.e., DatetimeIndex, PeriodIndex and TimedeltaIndex.
Number of periods (or increments) to shift by, can be positive or negative.
Frequency increment to shift by. If None, the index is shifted by its own :None:None:`freq`
attribute. Offset aliases are valid strings, e.g., 'D', 'W', 'M' etc.
Shifted index.
Shift index by desired number of time frequency increments.
Series.shift
Shift values of Series.
Put the first 5 month starts of 2011 into an index.
This example is valid syntax, but we were not able to check execution>>> month_starts = pd.date_range('1/1/2011', periods=5, freq='MS')
... month_starts DatetimeIndex(['2011-01-01', '2011-02-01', '2011-03-01', '2011-04-01', '2011-05-01'], dtype='datetime64[ns]', freq='MS')
Shift the index by 10 days.
This example is valid syntax, but we were not able to check execution>>> month_starts.shift(10, freq='D') DatetimeIndex(['2011-01-11', '2011-02-11', '2011-03-11', '2011-04-11', '2011-05-11'], dtype='datetime64[ns]', freq=None)
The default value of :None:None:`freq`
is the :None:None:`freq`
attribute of the index, which is 'MS' (month start) in this example.
>>> month_starts.shift(10) DatetimeIndex(['2011-11-01', '2011-12-01', '2012-01-01', '2012-02-01', '2012-03-01'], dtype='datetime64[ns]', freq='MS')See :
The following pages refer to to this document either explicitly or contain code examples using this.
pandas.core.groupby.groupby.GroupBy.shift
pandas.core.frame.DataFrame.shift
pandas.core.indexes.datetimelike.DatetimeIndexOpsMixin.shift
pandas.core.series.Series.shift
pandas.core.generic.NDFrame.shift
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them