Im trying to convert a dataframe to a dict, with unique values from a coloumn (col 3) as keys.
From this:
Col1 Col2 Col3
0 a b x
1 c d x
2 e f y
3 g h y
To this:
{x:[[a,b][c,d]],y:[[e,f],[g,h]]}
With the following code i get tuples, which really doesnt do the trick for me.
new_dict = df.groupby('col3').apply(lambda x: list(zip(x['col1'],x['col2']))).to_dict()
output:
{x:[(a,b),(c,d)],y:[(e,f),(g,h)]}