pandas groupby dict code example
Example 1: 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]}
Example 2: convert pandas group to dict
res = dict(tuple(d.groupby('a')))
Example 3: dict from group pandas
dict(tuple(df.groupby('a')))