title: pandas json_normalize all columns have nested dictionaries flattening
body: <p>I have a nested dictionary (json) which was returned from the unofficial google dictionary API.</p>
  
  <p>Which looks like this:</p>
  
  <pre><code>{'word': 'slack',
   'phonetic': '/slak/',
   'meaning': {'adjective': [{'definition': 'Not taut or held tightly in position; loose.',
      'example': 'a slack rope',
      'synonyms': ['loose',
       'limp',
       'not taut',
       'not tight',
       'hanging',
       'flapping']},
     {'definition': '(of business) characterized by a lack of work or activity; quiet.',
      'example': 'business was rather slack'},
     {'definition': 'Having or showing laziness or negligence.',
      'example': 'slack accounting procedures',
      'synonyms': ['lax',
       'negligent',
       'neglectful',
       'remiss',
       'careless',
       'slapdash',
       'slipshod',
       'lackadaisical',
       'lazy',
       'inefficient',
       'incompetent',
       'inattentive',
       'offhand',
       'casual',
       'disorderly',
       'disorganized']},
     {'definition': '(of a tide) neither ebbing nor flowing.',
      'example': 'soon the water will become slack, and the tide will turn'}],
    'noun': [{'definition': 'The part of a rope or line which is not held taut; the loose or unused part.',
      'example': 'I picked up the rod and wound in the slack',
      'synonyms': ['looseness', 'play', 'give']},
     {'definition': 'Casual trousers.'},
     {'definition': 'A spell of inactivity or laziness.',
      'example': 'he slept deeply, refreshed by a little slack in the daily routine',
      'synonyms': ['lull',
       'pause',
       'respite',
       'spell of inactivity',
       'interval',
       'break',
       'hiatus',
       'breathing space']}],
    'verb': [{'definition': 'Loosen (something, especially a rope).'},
     {'definition': 'Decrease or reduce in intensity, quantity, or speed.',
      'example': 'the flow of blood slacked off',
      'synonyms': ['reduce',
       'lessen',
       'slacken',
       'slow',
       'ease off',
       'ease up']},
     {'definition': 'Work slowly or lazily.',
      'example': 'she reprimanded her girls if they were slacking',
      'synonyms': ['idle',
       'shirk',
       'be inactive',
       'be lazy',
       'be indolent',
       'sit back and do nothing',
       'waste time',
       'lounge about']},
     {'definition': 'Slake (lime).'}],
    'adverb': [{'definition': 'Loosely.',
      'example': 'their heads were hanging slack in attitudes of despair'}]}}
  </code></pre>
  
  <p>This is the meaning of the word <strong>slack</strong>.
  To get this meaning we can google the meaning or simply use the following code:</p>
  
  <pre><code>import numpy as np
  import pandas as pd
  import json
  from pandas.io.json import json_normalize
  from io import StringIO
  import requests
  
  word = 'slack'
  url =  'https://googledictionaryapi.eu-gb.mybluemix.net/?define=' + word
  response = requests.get(url)
  content = response.content.decode('utf-8') # list of ugly strings
  j = json.loads(content) # json list having nested dictionary
  j = j[0]
  j
  </code></pre>
  
  <p>Now, the dictionary j has three keys. </p>
  
  <pre><code>j.keys() # dict_keys(['word', 'phonetic', 'meaning'])
  </code></pre>
  
  <p>I am mainly interested in the meaning:</p>
  
  <pre><code>j['meaning'].keys() # dict_keys(['adjective', 'noun', 'verb', 'adverb'])
  </code></pre>
  
  <p>To get the pandas dataframe I used following code:</p>
  
  <pre><code>json_normalize(data=j['meaning'])
  </code></pre>
  
  <p>This gives a dataframe with only 4 columns.</p>
  
  <p>Here, each part of speech ( adjective, noun, etc) must have 'definition' key and 'example' and 'synonyms' are optional.</p>
  
  <pre><code>j['meaning']['adjective'][0].keys() # dict_keys(['definition', 'example', 'synonyms'])
  </code></pre>
  
  <p>How to get the dataframe with 4 * 3 = 12 columns, with column names like <code>adjective_definition</code>, <code>adjective_example</code>, ...., <code>verb_synonyms</code>?</p>
  
  <p>I tried to get some ideas from following links:  </p>
  
  <p><a href="http://pandas.pydata.org/pandas-docs/version/0.17.0/generated/pandas.io.json.json_normalize.html" rel="nofollow noreferrer">http://pandas.pydata.org/pandas-docs/version/0.17.0/generated/pandas.io.json.json_normalize.html</a><br>
  <a href="https://www.kaggle.com/jboysen/quick-tutorial-flatten-nested-json-in-pandas/notebook" rel="nofollow noreferrer">https://www.kaggle.com/jboysen/quick-tutorial-flatten-nested-json-in-pandas/notebook</a><br>
  <a href="https://stackoverflow.com/questions/47242845/pandas-io-json-json-normalize-with-very-nested-json">pandas.io.json.json_normalize with very nested json</a>  </p>
  
  <p>But, could not solve the problem. Help will be appreciated.</p>