Answers for "pandas group by to dict"

2

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]}
Posted by: Guest on October-02-2020
0

convert pandas group to dict

res = dict(tuple(d.groupby('a')))
Posted by: Guest on May-19-2020

Python Answers by Framework

Browse Popular Code Answers by Language