Closed
Description
The example below always generate an error TypeError: 'NoneType' object is not subscriptable
as metadata
object is not always present.
file = [{'values': ['1', '2'], 'metadata': {'name': 'first_value'}},
{'values': ['3', '4'], 'metadata': None}]
df = json_normalize(file,
record_path='values',
meta=[['metadata', 'name']],
errors='ignore')
The metadata
object is dynamic and nested, so I am concerned why it doesn't generate something like this:
0 | metadata.name |
---|---|
1 | first_value |
2 | first_value |
3 | nan |
4 | nan |
as I set errors='ignore'
@WillAyd Could you please explain the best way to handle this?
Originally posted by @sann05 in #21830 (comment)