[Tutor] Aaagh! Stack arrays!?! calc average
Ben Sherman
bensherman at gmail.com
Tue May 1 20:07:23 CEST 2007
On 5/1/07, John Washakie <washakie at gmail.com> wrote:
>
> Oops, I meant it crashes at line 7..
>
> >
> > 1) tinit = data[0][0]
> > 2) for d in data:
> > 3) if d[0] <= tinit+60:
> > 4) sum = sum+d
> > 5) else:
> > 6) avg = sum/len(sum)
> > 7) newData = append([newData],[avg],axis=0)
> > 8) tinit = d[0]
> >
You didn't include your append() function here, so it's hard to tell whats
going on. Perhaps you mean to use newData.append(avg) assuming that newData
is a list?
Also, your average looks funky. If sum is something you can get a len() on,
you can't divide it. It should be bombing here.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070501/0c3a1fe7/attachment.html
More information about the Tutor
mailing list