[SciPy-user] arrays mean & NaN...

Matthieu Brucher matthieu.brucher@gmail....
Sat Sep 8 08:52:21 CDT 2007

2007/9/8, fred <fredmfp@gmail.com>:
> Hi,
> When I compute the mean of several arrays (the mean is an array),
> and if one of several of these arrays has NaN in a given cell, the
> mean of this cell is also NaN.
> I would like to have the mean of the all non-NaN is this cell.
> How could I do this ?
> PS: To be more efficient, I don't mind if it is not the "right" mean, ie
> divided by the real
> number of non-NaN, but the number of arrays.
> But, just curious, I'm also interested by a solution for the right mean
> ;-)


You could use numpy.nansum()/numpy.sum(~numpy.isnan()) or something like
this ?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/scipy-user/attachments/20070908/200dc87b/attachment.html 

More information about the SciPy-user mailing list