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

Joris De Ridder Joris.DeRidder@ster.kuleuven...
Fri Mar 21 21:51:27 CDT 2008


numpy.diff
See http://www.scipy.org/Numpy_Example_List

J.



On 22 Mar 2008, at 03:43, Chris Withers wrote:

> 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
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion


Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm



More information about the Numpy-discussion mailing list