staircase.Stairs.diff#

Stairs.diff(delta: int | float | pd.Timedelta) Stairs#

Returns a stairs instance corresponding to the difference between the step function corresponding to self and the same step-function translated by delta.

Parameters
deltaint, float or pandas.Timedelta

the amount by which to translate. A pandas.Timestamp 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
Stairs

See also

Stairs.shift

Examples

../../_images/staircase-Stairs-diff-1.png

Note that the definition of diff is designed to be consistent with pandas.Series.diff()

>>> 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))).diff(1)
0    NaN
1    0.0
2   -0.5
3   -1.0
4    0.0
5    0.0
6    1.0
dtype: float64
>>> pd.Series(s2.diff(1)(range(7)))
0    0.5
1    0.0
2   -0.5
3   -1.0
4    0.0
5    0.0
6    1.0
dtype: float64