将DataFrame转换为键的字典作为索引,将值转换为其他列作为列表

时间:2019-04-03 06:37:47

标签: python pandas list dictionary collections

将熊猫数据框设为

index    A    B
1        5    6
2        8    10

将其转换为字典,例如

{'1':[5, 6], '2':[8, 10]}

在python中可以转换吗?如果是,请以有效的方式提供代码。

0 个答案:

没有答案