将多个字典转换为数据框

时间:2021-03-01 16:21:27

标签: python json dataframe

我从一个 url 中提取了 JSON 数据。结果是多个字典。如何将此字典转换为数据框,例如:

{ "transaction_hash":"33623a4c","block_hash":"ab5bad19","block_number":"462235","block_timestamp":"2017-04-17 04:09:51 UTC","index":"31","spent_transaction_hash":"3647c5893a6511f5e4012f6b85ecfb8e01320ea726ec423270883e0a58d45d85","spent_output_index":"1","sequence":"4294967294","required_signatures":"1","type":"pubkeyhash","addresses":["1NvpBYpFMm9ukFWDQbJcBJL87xwN8TKh64"],"value":1548162}
{ "transaction_hash":"769cddc3","block_hash":"af87bd35","block_number":"586761","block_timestamp":"2019-07-24 04:11:37 UTC","index":"15","spent_transaction_hash":"6651720fd6866ff5ba20316a0d133c10c769f390044cb90dec920e8f3547ba0b","spent_output_index":"0","sequence":"4294967295","required_signatures":"1","type":"pubkeyhash","addresses":["17wSLPkhGWUkS8sE6Bsk4GRJNo4P73HwKr"],"value":214979}




transaction_hash-------block_hash-----block_number------block_timestamp......

    33623a4c-----------ab5bad19---------462235--------2017-04-17 04:09:51 UTC.....
    769cddc3-----------af87bd35---------586761--------2019-07-24 04:11:37 UTC.....

提前致谢

1 个答案:

答案 0 :(得分:0)

可以使用 pd.DataFrame.from_dict() 方法直接从字典中创建数据框。

https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.from_dict.html