0

I have a need to take a complex json/dict object, and convert it in to a single row dataframe, with a column for each key/value pair. I would like each column header to describe the parent/child relationship from the original object, for example:

{
   "fname":"Mickey",
   "lname":"Mouse",
   "Id":"12345",
   "education":[
      {
         "school":"acme University",
         "degree":"Doctor of Philosophy (PhD)"
      },
      {
         "school":"super university",
         "degree":"Master of Science (MS)"
      }
   ],
   "location":"New York, NY",
   "experience":[
      {
         "description":"I Work Hard",
         "title":"Manager",
         "work":"Hogwarts"
      },
      {
         "description":"I work Harder.",
         "title":"Senior Manager",
         "work":"hundred acre wood"
      }
   ],
   "startTime":4352,
   "endTime":234234
}

would become:

fname lname Id education.school1 education.degree1 education.school2
Mickey Mouse 12345 acme University Doctor of Philosophy (PhD) super university

I have tried "json_normalize", but it only flattens the first level.

Thank you in advance!

Peter Csala
  • 17,736
  • 16
  • 35
  • 75

0 Answers0