imports json
df = pd.read_json("C:/xampp/htdocs/PHP code/APItest.json", orient='records')
print(df)
I would like to create three columns extra: ['name','logo','ico_score']
instead of the 'main'
column
I have tried:
df2 = df.join(pd.DataFrame(list(json.loads(d).values())[0] for d in df.pop('main')) )
but gets this TypeError:
the JSON object must be str, bytes or bytearray, not dict
I hope someone can help me find a way, so i can end up with a data table for statistics. Best regards the student.
This is how my json data looks like:
[
{
"id": "126",
"main": {"name": "SONM", "logo": "link", "ico_score": "6.7"},
"links": {"url": "link"},
"finance": {"raised": "42000000"},
},
{
"id": "132",
"main": {"name": "openANX", "logo": "link", "ico_score": "5.7"},
"links": {"url": "link"},
"finance": {"raised": "18756937"},
},
{
"id": "166",
"main": {"name": "Boul\\u00e9", "logo": "link", "ico_score": "5.6"},
"links": {"url": "link"},
"finance": {"raised": ""},
},
]