This is my json
{
"fInstructions": [
{
"id": 155,
"type":"finstruction",
"ref": "/spm/finstruction/155",
"iLineItem":[
{
"id": 156,
"type":"ilineitem",
"ref": "/spm/ilineitem/156",
"creationDate": "2018-03-09",
"dueDate":"2018-02-01",
"effectiveDate":"2018-03-09",
"frequency":"01",
"coveredPeriodFrom":"2018-02-28",
"coveredPeriodTo":"2018-02-28",
"statusCode":"PRO",
"amount": 6
},
{
"id": 157,
"type":"ilineitem",
"ref": "/spm/ilineitem/157",
"creationDate": "2018-03-09",
"dueDate":"2018-02-01",
"effectiveDate":"2018-03-09",
"frequency":"01",
"coveredPeriodFrom":"2018-03-01",
"coveredPeriodTo":"2018-03-31",
"statusCode":"PRO",
"amount": 192
}
]
}
]
}
If I do:
json_normalize(data['fInstructions'], record_path=['iLineItem'])
I get two rows as expected with all the ILIs. However, I want to also have the parent attributes id, type in the result set. To that I try:
json_normalize(df_data_1['fInstructions'], record_path=['iLineItem'], meta=['id', 'type'])
But then I get: ValueError: Conflicting metadata name id, need distinguishing prefix
So I try:
json_normalize(df_data_1['fInstructions'], record_path=['iLineItem'], meta=['fInstructions.id'])
Which gives me:
KeyError: "Try running with errors='ignore' as key 'fInstructions.id' is not always present"