JSON使用Pandas Keys作为标头到CSV Python3
嘿
我使用了一个虚拟API为我生成JSON产品,我想使用 pandas
您可以看到以上python代码
output> output
,我想要的是要成为标题的关键
:{'' id':2,'title':'iPhone x','description':}
to:
Id Title description
1 iPhoneX descriptionx
2 iPhoneX descriptionx
Hey
i used a dummy api generating Json products for me and i want to convert it to CSV file using Pandas
as you can see this the python code above
Output
and what i want is Keys to be headers
From: {'id': 2, 'title': 'iPhone X', 'description':}
To :
Id Title description
1 iPhoneX descriptionx
2 iPhoneX descriptionx
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
smippet
r.json()
实际上返回带有4个键的字典:products
,total
,skip
和<代码>限制。看来您只对products
感兴趣,因此只需修改程序以添加[“ products”]
r.json()
足够:这输出:
The snippet
r.json()
actually returns a dictionary with 4 keys:products
,total
,skip
andlimit
. It seems that you're only interested inproducts
, so simply modifying the program to add["products"]
afterr.json()
is sufficient:This outputs:
答案。
我想这是我们不需要熊猫来做到这一点的
i guess this is the answer
we don't need pandas to do this.