I have a dictionary dico that i created it with this code :
dico = {}
for index, row in data.iterrows():
tup = (row['OsId'], row['BrowserId'])
if tup not in dico:
dico[tup] = []
dico[tup].append(row['PageId'])
[print(f"{key} : {value}") for key, value in dico.items()]
here a sample of dico :
combination : list of pages :
(99, 14) : [789615, 1158132, 789615, 789615, 1109643, 789615, 1184903]
(33, 16) : [955761, 955764, 955767, 955761, 955764, 955764, 1154705, 955761]
(12, 99) : [1068379, 1184903, 955764, 955761, 1184903, 955764]
(11, 99) : [1187774]
I am looking for a way to change the dico to replace the combination value by it's index in the list of combinations
For example i have the list of combination : (99, 14), (33, 16), (12, 99), (11, 99)
The expected result should be :
0 : [789615, 1158132, 789615, 789615, 1109643, 789615, 1184903]
1 : [955761, 955764, 955767, 955761, 955764, 955764, 1154705, 955761]
2 : [1068379, 1184903, 955764, 955761, 1184903, 955764]
3 : [1187774]
Any idea please to do it? thanks