[Tutor] Aaagh! Stack arrays!?! calc average

John Washakie washakie at gmail.com
Tue May 1 19:37:31 CEST 2007

Hello, I'm trying to calculate an average for columns in my
array(data), there's a catch though, I want to create a new array of
shorter length (NOTE: this crashes at line 8):

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]

I cannot figure out how to append, column_stack, or otherwise deal
with the newData array! Input on this simple task would be greatly

More information about the Tutor mailing list