pd to dictionary records code example
Example 1: dataframe to dict without index
df.to_dict('list')
Example 2: dataframe to dictionary using index as key
#Use the Dataframe index as the key of the dictionary
df.to_dict('index')
df.to_dict('list')
#Use the Dataframe index as the key of the dictionary
df.to_dict('index')