[Numpy-discussion] new question - summing a list of arrays
Alan G Isaac
Tue Mar 18 10:23:06 CDT 2008
On Tue, 18 Mar 2008, Chris Withers apparently wrote:
> Say I have an aribtary number of arrays:
> arrays = [array([1,2,3]),array([4,5,6]),array([7,8,9])]
> How can I sum these all together?
But must they be in a list?
An array of arrays (i.e., 2d array) is easy to sum.
> My only solution so far is this:
> sum = arrays
> for a in arrays[1:]:
> sum += a
> ...which is ugly :-S
And changes the first array!
More information about the Numpy-discussion