So I got this JSON
{
'A': {
'total': '$ 28.919',
'transacciones': 63,
'promedio': '$ 459'
},
'B': {
'total': '$ 17.169',
'transacciones': 27,
'promedio': '$ 635'
}
}
And i'm trying to return a table using json_normalize(data) with A/B as columns and total/transacciones/promedio as rows but instead, im getting this:
A.total A.transacciones A.promedio B.total B.transacciones B.promedio
0 $ 28.919 63 $ 459 $ 17.169 27 $ 635
What am I doing wrong? I've looked online but couldn't find an answer.
CodePudding user response:
Try just using the pd.DataFrame()
constructor:
j = {
'A': {
'total': '$ 28.919',
'transacciones': 63,
'promedio': '$ 459'
},
'B': {
'total': '$ 17.169',
'transacciones': 27,
'promedio': '$ 635'
}
}
df = pd.DataFrame(j)
Output:
>>> df
A B
total $ 28.919 $ 17.169
transacciones 63 27
promedio $ 459 $ 635