title: 4-level nested dictionaries convert to pandas dataframe python
body: <p>I have 4-level nested dictionaries and want to convert to pandas data frame or panel data form to extract csv. I want every cell to have information
  from nested dictionaries.  </p>
  
  <p>I have nested dictionaries like below, but have more keys and values in actual data. </p>
  
  <pre><code>{2008: {'Barack Obama': {1: {'Author': 'Barack Obama',
      'City': [],
      'Title': 'Keynote Address at the 2004 Democratic National Convention',
      'Type': 'address',
      'Year': 2008},
     2: {'Author': 'Barack Obama',
      'City': ['Springfield'],
      'Title': 'Remarks Announcing Candidacy for President in Springfield,     Illinois',
      'Type': 'remarks',
  'Year': 2008},
     3: {'Author': 'Barack Obama',
  'City': ['Chicago'],
  'Title': 'Remarks at the AIPAC Policy Forum in Chicago',
  'Type': 'remarks',
  'Year': 2008}},
  
   'Bill Richardson': {1: {'Author': 'Bill Richardson',
  'City': [],
  'Title': 'Iraq Speech to New Hampshire Democratic State Party State Central Committee',
  'Type': 'speech',
  'Year': 2008},
     2: {'Author': 'Bill Richardson',
  'City': [],
  'Title': 'Address to the DNC Winter Meeting',
  'Type': 'address',
  'Year': 2008},
     3: {'Author': 'Bill Richardson',
  'City': [],
  'Title': 'Speech: The New Realism and the Rebirth of American Leadership',
  'Type': 'speech',
  'Year': 2008}}},
  
  
  2012: {'Barack Obama': {1: {'Author': 'Barack Obama',
  'City': ['Parma'],
  'Title': '535 - Remarks at a Campaign Rally in Parma, Ohio',
  'Type': 'remarks',
  'Year': '2012'},
     2: {'Author': 'Barack Obama',
  'City': ['Sandusky'],
  'Title': '534 - Remarks at a Campaign Rally in Sandusky, Ohio',
  'Type': 'remarks',
  'Year': '2012'},
     3: {'Author': 'Barack Obama',
  'City': [],
  'Title': '533 - Remarks at a Campaign Rally in Maumee, Ohio',
  'Type': 'remarks',
  'Year': '2012'}}}
  </code></pre>
  
  <p>and I want to convert to like this data frame.</p>
  
  <pre><code>Year    Author1        No.   Author          City           Title   Type    Year
  2008    Barack Oabama   1    Barack Oabama     []           ....    address  2008
  2008    Barack Oabama   2    Barack Oabama   ['Springfield'] ....   remarks    2008
  2008    Barack Oabama   3    Barack Oabama   ['Chicago']     ....   remarks    2008
  
   .......................
  
  2008    Bill Richardson   1    Bill Richardson  []          ....   remarks    2008
  2008    Bill Richardson   2    Bill Richardson  []          ....   address    2008
  2008    Bill Richardson   3    Bill Richardson  []          ....   speech    2008
  
  .............
  
  2012    Barack Oabama   1    Barack Oabama   ['Parma']     ....   remarks    2012
  2012    Barack Oabama   2    Barack Oabama   ['Sandusky']     ....   remarks    2012
  2012    Barack Oabama   3    Barack Oabama   []               ....   remarks    2012
  .....................
  </code></pre>
  
  <p>I've read some answers that using for loops to make into data frame, but it gives the first column merged indexes but I do want to have every cell has the information from the dictionaries. Any suggestions? Thanks!!</p>
  
  <p>I've tried this code, and this does not give what I want, it gives me with merged index cell on the first columns and it does not apply to 4-level nested dictionaries. I modified one more for loop, but the final form has three tuples, which is not what I want.</p>
  
  <pre><code>pd.DataFrame.from_dict({(i,j): user_dict[i][j] 
                         for i in user_dict.keys() 
                         for j in user_dict[i].keys()},
                     orient='index')
  </code></pre>