Issue
I am trying to read in the JSON structure below into pandas dataframe, but it throws out the error message:
ValueError: Mixing dicts with non-Series may lead to ambiguous ordering.
Json data:
{
"status": {
"statuscode": 200,
"statusmessage": "Everything OK"
},
"result": [{
"id": 22,
"club_id": 16182
}, {
"id": 23,
"club_id": 16182
}, {
"id": 24,
"club_id": 16182
}, {
"id": 25,
"club_id": 16182
}, {
"id": 26,
"club_id": 16182
}, {
"id": 27,
"club_id": 16182
}]
}
How do I get this right? I have tried the script below...
j_df = pd.read_json('json_file.json')
j_df
with open(j_file) as jsonfile:
data = json.load(jsonfile)
Solution
If you just need the result part in a dataframe, then here is the code to help you.
import json
import pandas as pd
data = json.load(open('json_file.json'))
df = pd.DataFrame(data["result"])
Answered By - Rao Sahab
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.