Numercial Reduction question
Fernando Pérez
fperez528 at yahoo.com
Sun Nov 18 10:53:32 EST 2001
> For example, I might have a 31 by 12 array (days by months) of
> data. Some cells have a special value in them to denote that there is
> no data for that day (either it's an invalid date, or there was no data
> for that day). I want to be able to collapse along the day axis (31) to
> create monthly data, say summing the values, or averaging the
> values.
I just mentioned masked arrays. But if you don't have fancy requirements,
just using where might do:
In[1]:= x=array([1,2,3,-99,4])
In[2]:= sum(x)
Out[2]= -89
In[3]:= sum(where(x==-99,0,x))
Out[3]= 10
cheers,
f
More information about the Python-list
mailing list