I have a data frame like this:
df
col1 col2
12 A
14 A
22 B
24 C
20 A
18 B
16 B
Now I want to add the values of col1 on the basis of col2 if col2 value occurs more than one time continuously. The final data frame should look like:
col1 col2
A 26
B 22
C 24
A 20
B 34
I can use groupby() but how to differentiate continuous conditions ?