Answers for "pandas dataframe to dictionary with duplicate index"

0

pandas dataframe to dictionary with duplicate index

d = df_test.set_index('b').groupby('b').apply(lambda x : x.to_numpy().tolist()).to_dict()
print (d)
{7: [[5, 1], [6, 0]], 17: [[15, 1], [16, 0]]}
Posted by: Guest on July-20-2021

Code answers related to "pandas dataframe to dictionary with duplicate index"

Browse Popular Code Answers by Language