Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

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]]}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #pandas #dataframe #dictionary #duplicate #index
ADD COMMENT
Topic
Name
2+1 =