Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

dataframe groupby to dictionary

In [433]: {k: list(v) for k, v in df.groupby('Column1')['Column3']}
Out[433]: {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+7 =