Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

dataframe groupby to dictionary

In [81]: df.groupby('Column1')['Column3'].apply(list).to_dict()
Out[81]: {0: [1], 1: [2, 3, 5], 2: [1, 2], 3: [4, 5], 4: [1], 5: [1, 2, 3]}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #dataframe #groupby #dictionary
ADD COMMENT
Topic
Name
9+5 =