I have as an output of my python script a pandas dataframe as follows:
id1 id_list
1 [10,11,12]
2 [14,15,16]
3 [17,18,19]
I would like to duplicate rows to as much as items that id_list contains, and attribute to every item in that list a rank corresponding to its position in the list.
The output I am looking for is as follows :
id1 id2 rank
1 10 1
1 11 2
1 12 3
2 14 1
2 15 2
2 16 3
3 17 1
3 18 2
3 19 3
Thank you for your help.