【发布时间】:2020-05-12 22:16:07
【问题描述】:
我有一个数据框,其中一列有一个嵌套字典列表。我正在尝试获取与特定键有关的值。
下面是 Dataframe 的样子:
sale_id, sale_detail
10001, [{
'compulsory_on_complete': True,
'name': 'Store Location', <-- Pull value corresponding to this as given in the next row
'value': 'London',
'value_id': 2},
{
'compulsory_on_complete': True,
'name': 'Product Category', <-- Pull value corresponding to this as given in the next row
'value': 'General',
'value_id': 5}]
10002, [{
'compulsory_on_complete': True,
'name': 'Store Location',
'value': 'Scotland',
'value_id': 2},
{
'compulsory_on_complete': True,
'name': 'Product Category',
'value': 'Supplies',
'value_id': 5}]
预期输出:
sale_id, store_location, product_category
10001, London, General
10002, Scotland, Supplies
【问题讨论】:
标签: pandas dictionary