Numpy difference between neighboring elements
numpy, python
Solution
There is the `diff` method:
a = range(5) # python list of numpy array
np.diff(a)
returns
array([1, 1, 1, 1])
Problem
I have algorithm of calculation of the difference between neighboring elements in pure python: ``` a = range(1000000) #it's numpy array in my case prev = a[0] b = [0, ] for i in a[1:]: b.append(i - prev) prev = i ``` Is there any way to rewrite this functions with Numpy?