Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/301.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python:将字典列表嵌套到数据框架中_Python_Pandas_List_Dataframe - Fatal编程技术网

Python:将字典列表嵌套到数据框架中

Python:将字典列表嵌套到数据框架中,python,pandas,list,dataframe,Python,Pandas,List,Dataframe,下面是数据结构的说明。。。它是一个具有内部列表的列表,每个列表包含两个词典 我想把它放进数据框,标题是:占有、得分和传播 [[{'hasOwnage':'0','score':'23','spread':'-0'}, {'HasOccession':'0','score':'34','spread':'0.0'}, [{'HasOwnage':'0','score':'','spread':'-7.5'}, {'HasOccupation':'0','score':'spread':'7.5'}

下面是数据结构的说明。。。它是一个具有内部列表的列表,每个列表包含两个词典

我想把它放进数据框,标题是:占有、得分和传播

[[{'hasOwnage':'0','score':'23','spread':'-0'},
{'HasOccession':'0','score':'34','spread':'0.0'}, [{'HasOwnage':'0','score':'','spread':'-7.5'},
{'HasOccupation':'0','score':'spread':'7.5'}, [{'HasOwnage':'0','score':'','spread':'-1'},
{'HasOccupation':'0','score':'spread':'1.0'}]

通常,上述结构是一个列表,其中包含3个列表,每个列表包含2个字典,其中包含2个元素

如何将这些转换为pandas dataframe?

列表并使用

列出并使用


拉斐尔,你的完美解决方案,拉斐尔,你的完美解决方案。
pd.DataFrame([k for item in initial_list for k in item])

    hasPossession   score   spread
0   0               23      -0
1   0               34      0.0
2   0                       -7.5
3   0                       7.5
4   0                       -1
5   0                       1.0