相关疑难解决方法(0)

将JSON API响应转换为pandas Dataframe

我正在努力将JSON API响应转换为pandas Dataframe对象.我已经阅读了类似问题/文档的答案,但没有任何帮助.我最接近的尝试如下:

r = requests.get('https://api.xxx')
data = r.text
df = pd.read_json(data, orient='records')
Run Code Online (Sandbox Code Playgroud)

返回以下格式:

0    {'type': 'bid', 'price': 6.193e-05, ...},

1    {'type': 'bid', 'price': 6.194e-05, ...},

3    {'type': 'bid', 'price': 6.149e-05, ...} etc
Run Code Online (Sandbox Code Playgroud)

数据的原始格式为:

{'abc': [{'type': 'bid', 
          'price': 6.194e-05, 
          'amount': 2321.37952545, 
          'tid': 8577050, 
          'timestamp': 1498649162}, 
         {'type': 'bid', 
          'price': 6.194e-05, 
          'amount': 498.78993587,
          'tid': 8577047, 
          'timestamp': 1498649151},
          ...]}
Run Code Online (Sandbox Code Playgroud)

我很高兴能够获得良好的文档.

python json pandas

5
推荐指数
1
解决办法
7653
查看次数

标签 统计

json ×1

pandas ×1

python ×1