Possible Duplicate:
avarage of a number of arrays with numpy without considering zero values
I am working on numpy and I have a number of arrays with the same size and shape. They are 500*500. It has some Null values. I want to have an array that is result of one by one element average of my original arrays. For example:
A=[ 1 Null 8 Null; Null 4 6 1]
B=[ 8 5 8 Null; 5 9 5 3]
the resulting array should be like:
C=[ 4.5 5 8 Null; 5 6.5 5.5 2]
How can I do that?
Update: As of NumPy 1.8, you could use np.nanmean instead of
scipy.stats.nanmean.If you have
scipy, you could use scipy.stats.nanmean:You can find other numpy-only (masked-array) solutions, here. Namely,