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

Kent Johnson kent37 at tds.net
Tue May 1 20:12:09 CEST 2007


John Washakie wrote:
> 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
> appreciated!!

Can you give some more details? What is newData? What do you want to add 
to it? what is the axis=0 for?

Kent


More information about the Tutor mailing list