I have come across an issue with the json_normalize function. When specifying a key which may be missing for an item, it throws a key error. As you can see, listPeople does not always exist in the file.
df = {'Links':[{'id' : 1,'Gender' : 'X'},
{'id' : 2,'Gender' : 'Y','listPeople' : [{'Person':'John', 'Age' : 42}] }
]
}
test = json_normalize(df, record_path= "listPeople", errors = "ignore")
print(test)
According to the documentation, using errors = "ignore" should do the trick, but this doesn't seem to be working?
Expected Output:
Person Age
NULL NULL
John 42