[SciPy-user] arrays mean & NaN...
Matthieu Brucher
matthieu.brucher at gmail.com
Sat Sep 8 09:52:21 EDT 2007
2007/9/8, fred <fredmfp at 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
> ;-)
Hi,
You could use numpy.nansum()/numpy.sum(~numpy.isnan()) or something like
this ?
Matthieu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20070908/200dc87b/attachment.html>
More information about the SciPy-User
mailing list