[Numpy-discussion] calculating the difference of an array

Manuel Wittchen manuel.wittchen@gmail....
Sat Jan 2 04:23:13 CST 2010


Hi,

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