![](/img/trans.png)
[英]How to print all the keys and values together from a nested dictionary in Python?
[英]Print Nested Dictionary Keys and values in a tabular format
我想將我的嵌套字典打印成表格格式,看起來像這樣:
**ID** **Count** **Time** **OutCount** **OutTime**
262 725 15:29 725 15:29
等等.....
我的嵌套字典是:
{'262': {'count': 725,'time': '15:29','outcount': 725,'outtime': '15:29'},
'343': {'count': 699,'time': '15:29','outcount': 699,'outtime': '15:29'},
'809': {'count': 695,'time': '15:29','outcount': 695,'outtime': '15:29'}
pd.DataFrame.from_dict(d, orient='index')
count time outcount outtime
262 725 15:29 725 15:29
343 699 15:29 699 15:29
809 695 15:29 695 15:29
或使用reset_index
pd.DataFrame.from_dict(d, orient='index').reset_index()
index count time outcount outtime
0 262 725 15:29 725 15:29
1 343 699 15:29 699 15:29
2 809 695 15:29 695 15:29
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.