Normalize a nested json file in Python


Suppose a list of objects: one, two, three,…

Every object is composed of name, foo1, and foo2 fields.


If the object is normalize using:

obj_row_normalize = pd.json_normalize( object_row,
                                  record_path =['foo2'],

The result is:

id  num_name  
1.1      one   
1.2      one 

Given that, how can be added to each resulting row as below:

id  num_name   name
1.1      one
1.2      one   one.two
Asked By: Diego Quirós



Change the record path to foo1:

pd.json_normalize(recs, record_path=['foo1'], meta='name') name
0     1.1  one
1     1.2   one.two  one
Answered By: C.Nivs
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.