简体   繁体   中英

Convert Pandas Dataframe to a nested dictionary

因此,我有一个像这样的熊猫数据框:用户名SchoolID年龄体重身高RankInClass我想做的是:制作一个具有关键用户名的字典和一个具有关键School ID的子字典该子字典将具有一个列表作为值(年龄,体重,身高,等级)可以有人指导如何实现这一目标吗?

okay first create the sub data frame you need to create let's say the name of that data frame variable is data and convert it from the pandas inbuilt function

data_dict = data.to_dict() 

it will work

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM