[SciPy-user] arrays mean & NaN...
Sat Sep 8 08:52:21 CDT 2007
2007/9/8, fred <firstname.lastname@example.org>:
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the SciPy-user