I have a two-dimensional array of data. I need to average every two rows, and return the average with an array half of the height. I also need to ignore all NaN values for averaging purposes. For example:
>>> x = numpy.array([[ 1, nan, 3, 4, 5],
... [ 6, 7, 8, 9, nan],
... [11, 12, 13, 14, nan],
... [16, nan, 18, 19, nan]])
And the function would need to return:
>>> x
array([[3.5, 7, 5.5, 6.5, 5],
[13.5, 12, 15.5, 16.5, nan]])
numpyhasmasked array, and i'd think you can specify the np.nan being the mask, then apply the averaging operation.