'Pandas groupby with each group treated as a unique group to get cumsum of another column

Similar question to this one

Pandas groupby with each group treated as a unique group

but instead of having the cumsum of df['dir'], the cumsum of another column should be gotten with the changing boolean 1, 0.

My desired output - I want new cummulative sum of new_exist as the boolean changes

df  = pd.DataFrame({"dir":[1,1,1,1,0,0,0,1,1,1,1,0,0,0],
                  "grp": [1,2,3,4,1,2,3,1,2,3,4,1,2,3,], 
                  "new_exist":[0.1,0.2,0.5,1,1,2,1,1,2,2,4,1,2,3,],
                  "new_exist_cum":[0.1,0.3,0.8,1.8,1,3,4,1,3,5,4,5,7,10,]  })


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source