def weightedAvg(weightedTimeseries):
    sumA = np.sum((np.where(ts.mask, 0.0, ts.data * weight) for ts, weight in
        weightedTimeseries), axis=0)
sumB = np.sum((np.where(ts.mask, 0.0, weight) for ts, weight in
    weightedTimeseries), axis=0)
return np.divide(sumA, sumB)
How to aggregate timeseries in Python?