On 22 Mar 2008, at 13:49, Chris Withers wrote:
> Joris De Ridder wrote:
>> numpy.diff
>> See http://www.scipy.org/Numpy_Example_List
>
> Cool :-)
>
> Both this and Hoyt's example do exactly what I want.
>
> I'm guessing diff is going to be more efficient though?
No, not really, diff has more fun
Joris De Ridder wrote:
> numpy.diff
> See http://www.scipy.org/Numpy_Example_List
Cool :-)
Both this and Hoyt's example do exactly what I want.
I'm guessing diff is going to be more efficient though?
cheers,
Chris
--
Simplistix - Content Management, Zope & Python Consulting
- htt
Try
result = A[1:] - A[:-1]
--Hoyt
On Fri, Mar 21, 2008 at 7:43 PM, Chris Withers <[EMAIL PROTECTED]> 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?
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?
>
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(res