【发布时间】:2018-04-29 02:09:16
【问题描述】:
我在 Python 中有一个具有不同键的字典列表(响应键存在于 all 中),我想将其转换为 Panda Dataframe,以便所有键值显示为带有 Response的行> 键值作为列重复。例如,以下列表
[ {'回应':1,'工作生活':5,'生活家庭':2,'家庭平衡':10}, {'Response': 2, '鼓励管理': 11, '管理职业': 1, '职业抱负': 4, '抱负发展': 8},{'Response': 3, 'encourage people': 15, 'people manager': 9, 'managers ask': 5, 'ask employees': 9} ]
应该变成三列数据框
Response | Attribute | Value
1, work life, 5
1, life family, 2
1, family balance, 10
2, encouragement management, 11
2, management career, 1
2, career aspirations, 4
2, aspirations develop, 8
3, encourage people, 15
3, people managers, 9
3, managers ask, 5
3, ask employees, 9
【问题讨论】:
标签: python pandas dictionary dataframe pandas-groupby