I have pandas Series of the type
a = pd.Series([1, 4,3,5, 7,5, 5,6,7,6, 7, 6,2,2, 6, 9])
and a numpy array of the type
b = np.array([0, 1,1,1, 0,0, 1,1,1,1, 0, 1,1,1, 0, 1])
Now I want to seperately generate averages of elements in a whenever there is a cluster of 1's in the corresponding parts of b, with the result
c = pd.Series([1, 4,4,4, 7,5, 6,6,6,6, 7, 3.3,3.3,3.3 6, 9])
Does someone have an idea how to do this nicely?