I have a transcription from an interview which I've converted into a df (I have only recently started learning the pandas framework). The structure of the df is as follows:
Timestamp Content Speaker
00:00:00.000-00:00:01.100 Content Speaker 1
00:00:03.470-00:00:07.760 Content Speaker 1
00:00:09.340-00:00:13.690 Content Speaker 1
00:00:13.690-00:00:13.760 Content Speaker 2
00:00:14.550-00:00:14.880 Content Speaker 2
00:00:17.000-00:00:30.510 Content Speaker 1
00:00:30.740-00:00:41.930 Content Speaker 2
What I want to achieve is to collapse/merge (sorry not sure which term is most suitable here) across speakers and and retain the start and end time for that part of the speaker. The output should look like the one below:
**Timestamp Content Speaker**
00:00:00.000-00:00:13.690 ContentContentContent Speaker 1
00:00:13.690-00:00:14.880 ContentContent Speaker 2
00:00:17.000-00:00:30.510 Content Speaker 1
00:00:30.740-00:00:41.930 Content Speaker 2
I don't think I can use groupby because it will not retain the hierarchical order of the speakers e.g. it will place all the rows for speaker 1 on top, then all the rows of speaker 2 further down. And from my understanding I cannot use merge or concatenate. I have the feeling this will be a much more complex operation than I was expecting. Any help/advice/pointers will be much appreciated. Thank you in advance.