I'm having a dataframe in this form
col_1 group_ids value
0 Name_A 1 1
1 Name_B 2 4
2 Name_C 4 2
3 Name_D 5 10
4 Name_E 6 14
The goal is to sum all the values that the group_ids are consecutive, which is to produce the following table
col_1 group_ids value consecutive_cumsum
0 Name_A 1 1 1
1 Name_B 2 4 5
2 Name_C 4 2 2
3 Name_D 5 10 12
4 Name_E 6 14 26
I got it to work with using itertuples(). But what could be a more efficient way to deal with it? Many thanks!