Have a Json file that is arrays containing arrays I can get all "parts" with with code below but unable to figure out the json_normalize parms usage to extract different levels within nested arrays?
ie want 'id' from vehicle array with 'id' from model array with all parts array
car | camry | "value":"engine","price":10.82
Thanks
f = open('sample.json')
data = json.load(f)
f.close()
df1 = json_normalize(data['vehicle'], 'model')
df2 = df1[['parts']]
ddf = pd.DataFrame(columns=['value','charge'])
for (index,row) in df2.iterrows():
if pd.notnull(row[0]):
e = row[0]
ddf.loc[index] = [e[0]['value'], e[0]['charge']]
{
"vehicle":[
{
"id":"car",
"model":[
{
"id":"camry",
"parts": [
{
"value":"engine",
"charge":10.82
} ] }
,
{
"id":"avelon",
"parts": [
{
"value":"seats",
"charge":538.26
} ] }
,
{
"id":"prius",
"parts": [
{
"value":"seats",
"charge":10.91
} ] }
,
{
"id":"corolla",
"markup": {
"value":"61"
}
,
"accessories": [
{
"value":"vvvvv"
}]
} ] } ] }