[Numpy-discussion] dunno what array operation I'm looking for...

Chris Withers chris@simplistix.co...
Fri Mar 21 21:43:04 CDT 2008


Hi All,

Say I have an array like:

 >>> measurements = array([100,109,115,117])

What do I do to it to get:

array([9, 6, 2])

Is the following really the best way?

 >>> result = []
 >>> for i in range(1,len(measurements)):
...   result.append(measurements[i]-measurements[i-1])
...
 >>> array(result)
array([9, 6, 2])

cheers,

Chris

-- 
Simplistix - Content Management, Zope & Python Consulting
            - http://www.simplistix.co.uk


More information about the Numpy-discussion mailing list