python convert dataframe to dictionary code example Example 1: pandas to dictionary df.to_dict('records') Example 2: dataframe to dict without index df.to_dict('list')