[Numpy-discussion] new question - summing a list of arrays
Tue Mar 18 10:42:43 CDT 2008
Chris Withers wrote:
> Hi All,
> 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?
> My only solution so far is this:
> sum = arrays
> for a in arrays[1:]:
> sum += a
> ...which is ugly :-S
sum = sum(array(sum(a) for a in arrays]))
Works also if arrays in list have different length ...
More information about the Numpy-discussion