I am trying to find a list of tuples with start and end values (i.e. rows) from a df2 dataframe looking over the index (the first or zero column df2[0]). df2 example:
COL0 COL1 COL2
4 x y # start 'tuple x' of COL1
5 i j
6 n m # end 'tuple n'
14 f a # start 'tuple f'
15 e b # end 'tuple e'
...
So COL0 consecutive values will form a group. If the next row is not consecutive (e.g. 6-14) then a new group starts. A selection could be the following:
Crit_a = df2[0][0] + 1 == df2[0][1]
As output, I am looking for a new df3 with per row the following:
COL0 COL1 COL2 COL3 COL4 ...
4 x y n m # start values and end values of COL1 and COL2
14 f a e b
I was looking at SO here and other locations. Thank you for you suggestions.