Open
Description
Research
-
I have searched the [pandas] tag on StackOverflow for similar questions.
-
I have asked my usage related question on StackOverflow.
Link to question on StackOverflow
Pandas json_normalize question
Question about pandas
I am trying to understand an issue I encounter with json_normalize. This may be a bug?
The following code:
import pandas
data = [{
"id": 1039835,
"status": "on_track",
"development_plan": {
"id": 23858,
"items": [{
"id": 176498,
"item_name": "itemname 1"
}, {
"id": 172450,
"item_name": "itemname 2"
}, {
"id": 172451,
"item_name": "itemname 3"
}
]
},
"user": {
"id": 714067
}
}
]
print(
pandas.json_normalize(data,
['development_plan', 'items'],
[['development_plan', 'id'],['status'],['user', 'id'],['user']],
errors = 'ignore'
)
)
Returns this dataframe:
id item_name development_plan.id status user.id user
0 176498 itemname 1 23858 on_track 23858 {'id': 714067}
1 172450 itemname 2 23858 on_track 23858 {'id': 714067}
2 172451 itemname 3 23858 on_track 23858 {'id': 714067}
The question is why the user.id is wrong? It returns the development_plan.id. Adding the complete user dictionary does return the correct user.id though.
Is this a bug or am I missing something?