我有以下输出 json,我尝试使用 pandas 将其转换为数据框json_normalize
。我能够达到跑步者的水平json_normalize(data, ['runners'])
,但我要达到前水平。
[{
u 'status' : u 'OPEN',
u 'isMarketDataDelayed' : False,
u 'numberOfRunners' : 9,
u 'complete' : True,
u 'bspReconciled' : False,
u 'runnersVoidable' : False,
u 'betDelay' : 0,
u 'marketId' : u '1.123264244',
u 'crossMatching' : False,
u 'totalMatched' : 4.22,
u 'version' : 1241856317,
u 'lastMatchTime' : u '2016-02-25T10:32:25.704Z',
u 'numberOfWinners' : 1,
u 'inplay' : False,
u 'numberOfActiveRunners' : 9,
u 'totalAvailable' : 39.26,
u 'runners' : [{
u 'status' : u 'ACTIVE',
u 'handicap' : 0.0,
u 'selectionId' : 10861647,
u 'totalMatched' : 0.0,
u 'adjustmentFactor' : 16.631,
u 'ex' : {
u 'availableToBack' : [{
u 'price' : 1.02,
u 'size' : 2.15
}
],
u 'availableToLay' : [],
u 'tradedVolume' : []
}
}, {
u 'status' : u 'ACTIVE',
u 'handicap' : 0.0,
u 'selectionId' : 10861648,
u 'totalMatched' : 0.0,
u 'adjustmentFactor' : 13.237,
u 'ex' : {
u 'availableToBack' : [{
u 'price' : 1.01,
u 'size' : 7.11
}
],
u 'availableToLay' : [],
u 'tradedVolume' : []
}
},
使用其他数据,我很容易做到这一点json_normalize(data, ['runners','ex'])
,但如果我在这种情况下这样做,我会得到
0
0 availableToBack
1 availableToLay
2 tradedVolume
3 availableToBack
4 availableToLay
5 tradedVolume
6 availableToBack
7 availableToLay
8 tradedVolume
9 availableToBack
10 availableToLay
11 tradedVolume
12 availableToBack
13 availableToLay
14 tradedVolume
15 availableToBack
16 availableToLay
17 tradedVolume
18 availableToBack
19 availableToLay
20 tradedVolume
21 availableToBack
22 availableToLay
23 tradedVolume
24 availableToBack
25 availableToLay
26 tradedVolume
27 availableToBack
28 availableToLay
29 tradedVolume
.. ...
它应该有列'availableToBack'
, 'availableToLay'
,'tradedVolume'