In order to get this to work, I had to wrap your example above in a list and piece it together.
d={
"LDL Cholesterol": {
"displayName": {
"en": "LDL Cholesterol",
"hi": "kls"
},
"sliderType": "NHHHH",
"high": 160,
"text": {
"en": "LDL",
"hi": "ldd"
}
},
"HDL/LDL Cholesterol Ratio": {
"displayName": {
"en": "HDL : LDL ratio",
"hi": "klas"
},
"sliderType": "LN",
"lowThresh": 0.33,
"text": {
"en": "",
"hi": "jla"
}
}
}
dl =[d]
df1 = pd.json_normalize(dl[0]['LDL Cholesterol'])
df2 = pd.json_normalize(dl[0]['HDL/LDL Cholesterol Ratio'])
df = pd.concat([df1, df2], axis=0)
df['Test Name'] = ['LDL Cholesterol', 'HDL/LDL Cholesterol Ratio']
Output
sliderType high displayName.en displayName.hi text.en text.hi lowThresh Test Name
0 NHHHH 160.0 LDL Cholesterol kls LDL ldd NaN LDL Cholesterol
0 LN NaN HDL : LDL ratio klas jla 0.33 HDL/LDL Cholesterol Ratio
If you need to put in a loop, you'll just have to rework the code to perhaps append rows as you go rather than concatenating like I've done.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…