Merge Overlapping Intervals on a column in python

Viewed 39

My dataFrame is:

df1 = {'ID': [1, 1,3], 'aa': [52, 52,55],'ab': [8285,2490,1000],'type': ['A','B','C'] }
df1 = pd.DataFrame(data=df1)
df1

    ID  aa  ab      type
0   1   52  8285    A
1   1   52  2490    B
2   3   55  1000    C

I want to merge overlapping intervals on the column "type" for each ID

Desired dataframe :

    ID  aa  ab      type
0   1   52  8285    A,B
1   1   52  2490    B,A
2   3   55  1000    C

A schema of the dataframe:

my schema

0 Answers
Related