try the following:
>>> np.nanmean(ngma_heat_daily)
This function discards NaN values ββfrom your array before accepting the average value.
Edit: the reason average(ngma_heat_daily[ngma_heat_daily != nan]) doesn't work is related to this:
>>> np.nan == np.nan False
according to the IEEE floating point standard, NaN is not equal to itself! You could do this instead to implement the same idea:
>>> average(ngma_heat_daily[~np.isnan(ngma_heat_daily)])
np.isnan , np.isinf , and similar functions are very useful for this type of data masking.
jakevdp
source share