I have a JSON file called “values.json” with this content:
{
"values": [{
"id": 2,
"value": "passed"
}, {
"id": 41,
"value": "passed"
}, {
"id": 73,
"value": "passed"
}, {
"id": 110,
"value": "failed"
}, {
"id": 122,
"value": "failed"
}, {
"id": 234,
"value": "passed"
}, {
"id": 238,
"value": "passed"
}, {
"id": 345,
"value": "passed"
}, {
"id": 653,
"value": "passed"
}, {
"id": 690,
"value": "failed"
}, {
"id": 5321,
"value": "passed"
}, {
"id": 5322,
"value": "failed"
}]
}
I try to convert it to dataframe with next code:
values_path = "values.json"
df = pd.read_json(values_path)
with open(values_path) as f:
d = json.load(f)
df = pd.json_normalize(d)
print(df)
However, I get the table with one column and one row:
values
0 [{'id': 2, 'value': 'passed'}, {'id': 41, 'val...
What do I do wrong? Or maybe there is something wrong with my JSON file? I will be thankful for any help!
New contributor
FeelTD is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.