Convert pandas DataFrame to a nested dict,df = pd.DataFrame.from_dict(data)