'Unable to json_normalize nested array of objects in pandas

I am trying to json_normalize the nested array of objects. I would like to extract the inner most array attribute (line_items.tax_lines.rate). I am not sure if there is any issue in mentioning hierarchy in meta.

 data2 = {
  "order_id":"1234",
  "created_at":"2015-01-01 00:00:00",
  "customer_id":"100",
  "line_items":[                         
    {
       "product_id":"5008798",
       "price":"5.99",
       "quantity":"1",
       "tax_lines":[                    
          {
             "price":"5.99",
             "rate":"0.06",
             "title":"State Tax"
          }
       ]                               
    }
  ]                                    
}


df = pd.json_normalize(data2, record_path=["line_items","tax_lines"], 
meta=["order_id", "created_at", ["line_items", "product_id"], ["line_items", "quantity"], ["line_items", ["tax_lines", "rate"]]])
print(df)

I am getting this error. Any suggestions how to resolve this

meta_keys = [sep.join(val) for val in _meta]
TypeError: sequence item 1: expected str instance, list found


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source