我认为您需要
json_normalize:
from pandas import json_normalizedf = json_normalize(d, 'abc')print (df) amount price tid timestamp type0 2321.379525 0.000062 8577050 1498649162 bid1 498.789936 0.000062 8577047 1498649151 bid
对于多个键,可以
concat与
listcomprehensionand
Dataframe构造函数一起使用:
d = {'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}], 'def': [{'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}]}df = pd.concat([pd.Dataframe(v) for k,v in d.items()], keys=d)print (df) amount price tid timestamp typeabc 0 2321.379525 0.000062 8577050 1498649162 bid 1 498.789936 0.000062 8577047 1498649151 biddef 0 2321.379525 0.000062 8577050 1498649162 bid 1 498.789936 0.000062 8577047 1498649151 bid



