Feb-22-2020, 09:20 PM
Ok, maybe I misunderstood something... We have a series:
In terms of pandas/shift this series could be rewriting as follows
where
[inline]x.shift(1) = [NaN, x[0], x[1], ...., x[N-1]]
x = [x[0], x[1], ..., x[N]][/inline]
Your series is
Output:x[0], x[1], x[2], .... , x[N]
and you are trying to computeOutput:(x[1]-x[0])/x[0], (x[2]-x[1])/x[1], ...., (x[N]-x[N-1])/x[N-1]
x[0]
is older than x[1]
, x[1]
is older than x[2]
, etc.In terms of pandas/shift this series could be rewriting as follows
(x - x.shift(1))/x.shift(1) = x/x.shift(1) - 1
where
[inline]x.shift(1) = [NaN, x[0], x[1], ...., x[N-1]]
x = [x[0], x[1], ..., x[N]][/inline]
Your series is
[-0.047169, 0.636350, 1.207707, -0.558628]
. So, 1.207707
is older than -0.558628
, isn't it?!