【发布时间】:2019-12-28 19:25:49
【问题描述】:
我有这个清单:
my_list = [['ga:date'], ['ga:country', 'ga:date'], ['ga:country', 'ga:date']]
并尝试对其进行迭代以获得值及其位置,如下所示:
date 1
country 1
date 2
country 1
date 2
它应该稍后存储在 pandas df 中,值可以不同,没有修复。
原来是字典列表:
my_original_list = [
[{'name': 'ga:date'}],
[{'name': 'ga:country'}, {'name': 'ga:date'}],
[{'name': 'ga:country'}, {'name': 'ga:date'}]
]
# But I got the values out of it in a list:
my_list = [li['name'] for li in my_original_list]
# the result
my_list = [
['ga:date'],
['ga:country', 'ga:date'],
['ga:country', 'ga:date']
]
已经想好怎么弄了,不胜感激
【问题讨论】:
标签: python pandas list loops dictionary