【发布时间】:2020-12-22 07:02:42
【问题描述】:
抱歉这个琐碎的问题:
我有一个 json 文件 first.json,我想用 pandas.read_json 打开它:
df = pandas.read_json('first.json') 给我下一个结果:
我需要的结果是一行以键('name'、'street'、'geo'、'servesCuisine' 等)作为列。我试图改变不同的“orient”参数,但它没有帮助。如何实现所需的DataFrame 格式?
这是我的 json 文件中的数据:
{
"name": "La Continental (San Telmo)",
"geo": {
"longitude": "-58.371852",
"latitude": "-34.616099"
},
"servesCuisine": "Italian",
"containedInPlace": {},
"priceRange": 450,
"currenciesAccepted": "ARS",
"address": {
"street": "Defensa 701",
"postalCode": "C1065AAM",
"locality": "Autonomous City of Buenos Aires",
"country": "Argentina"
},
"aggregateRatings": {
"thefork": {
"ratingValue": 9.3,
"reviewCount": 3
},
"tripadvisor": {
"ratingValue": 4,
"reviewCount": 350
}
},
"id": "585777"
}
【问题讨论】:
标签: python json pandas dictionary