-
泛舟湖上清波郎朗
IIUC,您可以编写一个列表理解并明智地连接您的数据帧轴。import pandas as pdd = [ {111: [1, 2, 3]}, {112:[4, 5, 6]}, {113:[7,8,9]}]df = pd.concat([pd.DataFrame.from_dict(inner_dict,orient='columns') for inner_dict in d],axis=1)print(df) 111 112 1130 1 4 71 2 5 82 3 6 9
-
繁星coding
试一试:collections.ChainMapfrom collections import ChainMapd = [{111: [1, 2, 3]}, {112:[4, 5, 6]}, {113:[7,8,9]}]df = pd.DataFrame({**ChainMap(*d[::-1])})Out[79]: 111 112 1130 1 4 71 2 5 82 3 6 9
-
芜湖不芜
import pandas as pda = [ {111: [1, 2, 3]}, {112:[4, 5, 6]}, {113:[7,8,9]}]for item in a: for k, v in item.items(): df[k] = vdf 111 112 1130 1 4 71 2 5 82 3 6 9
-
侃侃尔雅
也许这个使用字典理解?data = [{ 111: [1, 2, 3] }, { 112: [4, 5, 6] }, { 113: [7,8,9] }]pd.DataFrame({ title: values for column in data for title, values in column.items() })但是,您可能最好将数据存储为大熊猫可以立即识别的字典。{ title: [value] }data = { 111: [1, 2, 3], 112: [4, 5, 6], 113: [7, 8, 9] }pd.DataFrame(data)