[Numpy-discussion] calculating the difference of an array

Manuel Wittchen manuel.wittchen at gmail.com
Sat Jan 2 05:23:13 EST 2010


I want to calculate the difference between the values of a
numpy-array. The formula is:

deltaT = t_(n+1) - t_(n)

My approach to calculate the difference looks like this:

for i in len(ARRAY):
	delta_t[i] = ARRAY[(i+1):] - ARRAY[:(len(ARRAY)-1)]

print "result:", delta_t

But I get a TypeError:
File "./test.py", line 19, in <module>
    for i in len(ARRAY):
TypeError: 'int' object is not iterable

Where is the mistake in the code?

Regards and a happy new year,
Manuel Wittchen

More information about the NumPy-Discussion mailing list