convert dataframe to dictionary of dictionary python code example
Example 1: pandas to dictionary
df.to_dict('records')
Example 2: convert pandas dataframe to dict with a column as key
df.set_index('columnName').T.to_dict()
df.to_dict('records')
df.set_index('columnName').T.to_dict()