1 回答
TA贡献1856条经验 获得超17个赞
您可以使用pandas.read_json
。从文档中,您可以指定 = 这是字典中预期 JSON 字符串格式的指示,例如orient
index
{index -> {column -> value}}
>>> import pandas as pd
>>> data = """
... {
... "2020-04-02T00:00:00.000Z": {
... "A": 133.25,
... "B": 0.000155642
... },
... "2020-04-03T00:00:00.000Z": {
... "A": 136.45,
... "B": 0.0001498913
... },
... "2020-04-04T00:00:00.000Z": {
... "A": 141.55,
... "B": 0.0001471562
... }
... }"""
>>>
>>> df = pd.read_json(data, orient='index')
>>> df
A B
2020-04-02 00:00:00+00:00 133.25 0.000156
2020-04-03 00:00:00+00:00 136.45 0.000150
2020-04-04 00:00:00+00:00 141.55 0.000147
添加回答
举报