I've got a problem reading a json-file to pandas dataframe. I've got a largish json-file with structure like this:
`{"name":
[{"header": -999.0,
"header2": -999.0,
"header3": -999.0,
.....
"headern": -999.0},
.....
.....
{"header": -999.0,
"header2": -999.0,
"header3": -999.0}],
"name2":
[{"header": -999.0,
"header2": -999.0,
"header3": -999.0,
.....
"headern": -999.0},
.....
.....
{"header": -999.0,
"header2": -999.0,
"header3": -999.0,]}
As expected data = pd.read_json(source,orient='index',lines=True)
reads the file so that "names" are indexes and the headers and values to one single column per row. I would like the table to be in this form:
header1 header2 ... header n
0 -999 -999 -999
1 -999 -999 -999
2 -999 -999 -999
I tried to loop through the file with codes like this (and many others)
import pandas as pd
for index, row in data.iterrows():
df.append(pd.DataFrame.from_dict(row), ignore_index=True)
But I cannot get the correct structure (e.g. the example above gives empty df). I am new to python&pandas so I probably don't have proper understanding of dataframes, but after reading documentations multiple times I still couldn't figure this out.