[Tutor] summing arrays, along a dimension

John washakie at gmail.com
Sat Sep 15 00:24:51 CEST 2007


>>> d
array([[0, 0, 1],
       [1, 2, 3],
       [2, 2, 4],
       [3, 6, 8]])
>>> e=reshape((d[:,-2]+d[:,-1]),(4,1))
>>> e
array([[ 1],
       [ 5],
       [ 6],
       [14]])

is there a better way to accomplish this?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070914/8fbe1f73/attachment.htm 


More information about the Tutor mailing list