staircase.Stairs.shift

Stairs.shift(delta)

Returns a stairs instance corresponding to a horizontal translation by delta

If delta is positive the corresponding step function is moved right. If delta is negative the corresponding step function is moved left.

Parameters:delta (int, float or pandas.Timedelta) – the amount by which to translate. A pandas.Timedelta is only valid when using dates. If using dates and delta is an int or float, then it is interpreted as a number of hours.
Returns:
Return type:Stairs

See also

Stairs.diff()

Examples

>>> stair_list = [s2, s2.shift(1), s2.shift(-1)]
>>> fig, axes = plt.subplots(nrows=1, ncols=3, figsize=(17,5), sharey=True, sharex=True)
>>> for ax, title, stair_instance in zip(axes, ("s2", "s2.shift(1)", "s2.shift(-1)"), stair_list):
...     stair_instance.plot(ax, label=title)
...     ax.set_title(title)
../_images/staircase-Stairs-shift-1.png

Note that the definition of shift is designed to be consistent with pandas.Series.shift

>>> pd.Series(s2(range(7)))
0    0.5
1    0.5
2    0.0
3   -1.0
4   -1.0
5   -1.0
6    0.0
dtype: float64
>>> pd.Series(s2(range(7))).shift(1)
0    NaN
1    0.5
2    0.5
3    0.0
4   -1.0
5   -1.0
6   -1.0
dtype: float64
>>> pd.Series(s2.shift(1)(range(7)))
0    0.0
1    0.5
2    0.5
3    0.0
4   -1.0
5   -1.0
6   -1.0
dtype: float64