Run
import pandas as pd # Take a DataFrame df = pd.DataFrame({ 'A': [2, 4, 6, 8], 'B': [1, 3, 5, 7], 'C': [10, 20, 30, 40]}) # Convert dataframe to list of dictionaries list_of_dicts = df.to_dict(orient='records') # Print the list of dictionaries print(list_of_dicts)
Output