19 Feb
2008
19 Feb
'08
2:08 p.m.
On Feb 19, 2008 11:38 AM, Neal Becker <ndbecker2@gmail.com> wrote:
adj_diff[i] = x[i] - x[i-1] : i > 1, x[i] otherwise
Well, x[1:] - x[:-1] will give the usual differences. If you need the leading x[0] prefix the x vector with a 0.
There's also numpy.diff, and the little known numpy.ediff1d
x=numpy.arange(10) numpy.ediff1d(x,to_begin=0) array([0, 1, 1, 1, 1, 1, 1, 1, 1, 1])