我有以下的JSON爲Web API響應:大熊貓數據幀從嵌套JSON
{"prices": [
{
"start_date": "2016-07-06T00:00:00+02:00",
"end_date": "2016-07-07T00:00:00+02:00",
"values": [
{
"start_date": "2016-07-06T00:00:00+02:00",
"end_date": "2016-07-06T00:30:00+02:00",
"upward_weighted": 45.66,
"downward_weighted": 20.63,
"upward_marginal": 30.1,
"downward_marginal": 12.8,
"updated_date": "2016-07-07T15:45:36+02:00"
},
{
"start_date": "2016-07-06T00:30:00+02:00",
"end_date": "2016-07-06T01:00:00+02:00",
"upward_weighted": 45.66,
"downward_weighted": 20.63,
"upward_marginal": 30.1,
"downward_marginal": 12.8,
"updated_date": "2016-07-07T15:45:36+02:00"
}
]}
]}
,我會檢索prices->值作爲一個數據幀。
start_date|end_date|upward_weighted|downward_weighted|...|updated_date|
----------|--------|---------------|-----------------|---|------------|
xxxxxxx |xxxxxxx |xxxxxxxx |xxxxxxx | |xxxxxx |
xxxxxxx |xxxxxxx |xxxxxxxx |xxxxxxx | |xxxxxx |
當我嘗試pandas.read_json(resp.content)我得到的僅包含一列「價格」與字典錯誤的數據幀。
是否可以告訴pandas.read_json()
使用價格 - >值創建DataFrame?
謝謝!有用!但是我不明白什麼是正在做json_normalize? – bAN