I have data frame like this:
Name1 Name2 Start End
aaa bbb 1 2
aaa bbb 2 22
aaa bbb 30 42
ccc ddd 100 141
ccc ddd 145 160
ccc ddd 160 178
How do I merge rows that the end time of the first row is equal to the start time of the second row, otherwise keep the row as is. The expected result look like this:
Name1 Name2 Start End
aaa bbb 1 22
aaa bbb 30 42
ccc ddd 100 141
ccc ddd 145 178
I can do this use iterrow, but I am wondering if there is a better way like apply or groupby to do so.