[Numpy-discussion] newbie question - summing a list of arrays
Chris Withers
chris@simplistix.co...
Tue Mar 18 10:39:31 CDT 2008
Alan G Isaac wrote:
> 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?
>
> Try N.sum(arrays,axis=0).
I assume N here is:
import numpy as N?
Yep, it is... and that works exactly as I expect.
Where are the docs for sum? Having had the book turn up as a massive PDF
with a poor index/toc, I'm finding it just as difficult to navigate as
the online docs :-(
(I, like most people on this list I'd guess, sadly don't have the time
to sit and read the whole book cover-to-cover to extract the 10-20% I
need to know :-S)
> But must they be in a list?
> An array of arrays (i.e., 2d array) is easy to sum.
Actually, I'm using a dict of arrays:
data = {
'series1':array([1,2,3]),
'series2':array([1,4,6]),
'date':array([datetime(...),datetime(...),datetime(...)]),
}
If that gives the idea?
Is there perhaps a better way to store these series?
(I'm a numpy newbie, I've skimmed the tutorial and it doesn't appear to
help here)
cheers,
Chris
--
Simplistix - Content Management, Zope & Python Consulting
- http://www.simplistix.co.uk
More information about the Numpy-discussion
mailing list