【发布时间】:2018-05-01 15:43:11
【问题描述】:
此问题是在Convert list of dictionaries containing another list of dictionaries to dataframe 发布的问题的补充
我被要求在我的 API 调用中添加一个参数,现在输出变得比上面的有点复杂。
输出是这样的:
insights = [ <Insights> "account_id": "1234",
"actions": [{'value': '5', 'action_type': 'add_to_cart', 'view': '5'}],
"cust_id": "xyz123",
"cust_name": "xyz",
}, <Insights> {
"account_id": "1234",
"cust_id": "pqr123",
"cust_name": "pqr",
}, <Insights> {
"account_id": "1234",
"actions": [
{'click': '8', 'value': '110', 'action_type': 'add_to_cart', 'view': '102'}, {'value': '12', 'action_type': 'purchase', 'view': '12'}
],
"cust_id": "abc123",
"cust_name": "abc",
}
]
现在我想要这样的解决方案
- account_id a2cart_view a2cart_click pur_view pur_click cust_id cust_name
- 1234 5 xyz123 xyz
- 1234 pqr123 pqr
- 1234 102 8 12 abc123 abc
我尝试使用上述链接中的解决方案,但当程序无法在其中一行中找到特定值时卡住了。
【问题讨论】:
标签: python pandas dictionary dataframe