I have a dataframe like this:
col1, col2
A 0
A 1
B 2
C 3
I would like to get the following:
{ A: [0,1], B: [2], C: [3] }
I tried:
df.set_index('col1')['col2'].to_dict()
but this is not entirely correct. The first problem that I have is "A", it repeats, I get only A: 1 (0 is overwritten). How to fix?
source
share