[Numpy-discussion] numpy.average(fooArray, axis=0): dropping nans from calculation
efiring at hawaii.edu
Thu Jul 13 19:44:15 CDT 2006
Webb Sprague wrote:
> Could someone recommend a way to average an array along the columns
> without propagating the nans and without turning them into some weird
> number which bias the result? I guess I can just keep using an
> indexing array for fooArray, but if there is somehting more graceful,
> I would love to know.
Something like this:
import numpy as N
ym = N.ma.masked_where(N.isnan(y), y)
yaverage = N.ma.average(ym)
> Boy missing data is a pain in the neck...
It certainly is, but Masked Arrays ease the pain.
More information about the Numpy-discussion