'Create a dictionary by keys and values
I'm trying to create a dictionary dico which contains elements like this:
<key> <values>
comb_element pageId1, pageId2, .. pageIdn
comb_element are elements of list of tuple comb :
I try with this code to create dico, but I didn't get the correct format of dico
comb=list(set(product(data['OsId'], data['BrowserId'])))
dico={}
dico[tuple(comb)] = list(data['PageId'])
Here what contains comb :
[(12, 16),
(33, 11),
(99, 11),
(11, 14),
(33, 14),
(32, 12),
(99, 14),
(11, 11),
(11, 17),
(32, 15),
(99, 17),
(33, 17),
(11, 99),
(33, 99),
(99, 99),
(12, 12),
(12, 15),
(32, 11),
(11, 16),
(33, 16),
(32, 14),
(99, 16),
(32, 17),
(32, 99),
(12, 11),
(12, 14),
(12, 17),
(12, 99),
(11, 12),
(99, 15),
(33, 12),
(99, 12),
(11, 15),
(32, 16),
(33, 15)]
Here the dataframe data: in case of (12, 16) as key I would like to attribute the lis of page : 1005581 and 1016529.
Cluster PageId OsId BrowserId
0 1005581 11 16
0 1016529 11 16
0 1016529 11 17
0 1016529 12 14
0 1016529 12 16
So for example, any idea to fix it? thanks
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
