【发布时间】:2021-07-13 21:59:08
【问题描述】:
尊敬的社区专家
我有一个 API 返回以下结构,我需要将其转换为 pandas 数据框。 我该怎么做才能创建这样的数据框?。
谢谢,埃尔南
[{'quoteSymbol': 'USDT',
'baseSymbol': 'ETH',
'orderBooks': [{'exchange': 'Bittrex',
'orderBook': {'asks': [{'price': '2112.20173745',
'quantity': '1.41879654'},
{'price': '2112.38300246', 'quantity': '1.41868464'},
{'price': '2112.56760000', 'quantity': '0.00209173'}],
'bids': [{'price': '2111.08708148', 'quantity': '1.41874566'},
{'price': '2110.87591399', 'quantity': '1.41874566'},
{'price': '2110.73500000', 'quantity': '2.35200000'}]}},
{'exchange': 'Binance',
'orderBook': {'asks': [{'price': '2092.91000000',
'quantity': '27.01387000'},
{'price': '2092.96000000', 'quantity': '3.34463000'},
{'price': '2092.97000000', 'quantity': '8.13200000'}],
'bids': [{'price': '2112.52000000', 'quantity': '1.45438000'},
{'price': '2112.36000000', 'quantity': '0.45074000'},
{'price': '2112.35000000', 'quantity': '0.97545000'}]}},
{'exchange': 'Bitstamp', 'orderBook': None}]}
【问题讨论】:
-
您希望数据框是什么?比如你想要哪些列以及它们如何从 JSON 映射?
-
列:报价代码、基准代码、交易所、订单类型(询价/出价)、价格、数量;订单簿