[SciPy-user] calculate average by excluding NaN value in Array

Ch B Komaki bkomaki@yahoo....
Mon Mar 30 04:58:23 CDT 2009


Dear Sirs/Madams
I wanna calculate average of some lists, but having Nan value makes difficult to calculate average of data , I wanna exclude the position has NaN.It should calculate  average of  the others instead  ;
for example;
>>> from numpy import *
>>> a=array([2.,3,4,5])
>>> b=([3.,2,4, NaN])
>>> average(array([a,b],"f"),axis=0)
array([ 2.5,  2.5,  4. ,  NaN], dtype=float32)
>>> 
I mean that I need is [2.5,2.5,4,5], instead.
thanks

ba salam ,
khili mamnu az javab tabrike shoma,
 man ye soal fanny (GIS) daram,
 Man chand ta data(MODIS , 8 daily) daram ke bari har mah 4 ta mojoud ast,
 hal mi kham mingin mahanh enjam deham vali pixel hai Nodata(Null) mask mishand,

man baid touri minagin begiram ke onja hai ke Nodata hast ,on data ke Nodata dar mohasebh miangin be kar nareh
 masalan  (einj a farz be ein ast ke 2 ta data darim);
Mean([2,3,4,5] ,[3,2,4, None])=[2.5,2.5,4,5]



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20090330/e00b41a3/attachment.html 


More information about the SciPy-user mailing list