I'm trying to transform this complex object into a pandas dataframe
data={
"customers": [
{
"a": 'true',
"addresses": [{"city": "Park"}],
"c": { "address1": "200"},
"d": "[email protected]",
"e": {"f": "sub"},
"h": 100,
}
]
}
I've tried several ways but none of them work.
df = pd.json_normalize(data,record_path='addresses',meta=['h'] ,record_prefix='adr'
,errors='ignore')
I always get the same error
KeyError: "Key 'addresses' not found. If specifying a record_path, all elements of data should have the path."
Your first key is "customers":
df = pd.json_normalize(
data=data.get("customers"),
record_path="addresses",
meta="h",
record_prefix="adr"
)
print(df)