从Python到Excel的字典出口列表
有一个名为“ aff”的列表,该列表由字典组成。看起来像这样:
Aff=[{('J', 0, 1): 36, ('J', 1, 1): 36, ('J', 2, 1): 42}, {('I', 0, 1): 36, ('I', 1, 1): 30}, {('H', 0, 1): 36, ('H', 1, 1): 36, ('H', 2, 1): 42}]
我想在Excel上获得这种结构:
-------Num------letter-----NV----Postion ---Q
1 J 0 1 36
1 J 1 1 36
1 J 2 1 42
2 I 0 1 36
2 I 1 1 36
...ect
have a list called 'Aff' that consists of dictionaries. It looks like this:
Aff=[{('J', 0, 1): 36, ('J', 1, 1): 36, ('J', 2, 1): 42}, {('I', 0, 1): 36, ('I', 1, 1): 30}, {('H', 0, 1): 36, ('H', 1, 1): 36, ('H', 2, 1): 42}]
and i wanna get this structure on EXCEL :
-------Num------letter-----NV----Postion ---Q
1 J 0 1 36
1 J 1 1 36
1 J 2 1 42
2 I 0 1 36
2 I 1 1 36
...ect
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的字典键包含元组,迫使您更改数据的结构。 IIUC
num
是列表中字典的索引(+1)。一旦制定数据,就可以使用
pandas.to_excel()
:print(df)
将输出:Your dictionary keys consisting of tuple forces you to change the structure of your data. IIUC
Num
is the index (+1) of the dictionary in the list.Once you flattened your data, you can use
pandas.to_excel()
:print(df)
would output: