I have a pandas dataframe that looks like as follows:
ID start end name
0 1 119 200 ss
1 1 118 156 ss
2. 1 110 200 ss
3 1 15 25 me
4 4 30 40 gg
5 4 30 55 gg
What I want do is to merge the overlapping intervals that have the same name (name column), and whose coordinates (start,end) overlap. So the resulting the dataframe will look like:
ID start end name
0 1 110 200 ss
1 1 15 25 me
2 4 30 55 gg
For example for ss in name column the lowest start value is 110 and the highest end value is 200. Therefore, the new dataframe will have 110 has start and 200 as end. How can I achieve this? Insights will be appreciated.