title: Lookup a dictionary of dictionaries in Python
body: <p>I am trying to lookup a dictionary of dictionaries and facing difficulty to do so.</p>
  
  <p>Data is a dictionary and looks like this:</p>
  
  <pre><code>data={'CME':{u'JPY': 0.525, u'USD': 3.305, u'CNH': 4.805},
  'EUREX':{u'USD': 3.305, u'GBP': 1.545, u'EUR': 0.375},
  'GOODM':{u'KRW': 0.0},
  'HKEX':{u'USD': 3.395, u'HKD': 3.565, u'CNH': 4.895},
  'KIS':{u'KRW': 0.0},
  'NLFX':{u'USD': 3.305},
  'OSE':{u'JPY': 0.615},
  'SGX':{u'JPY': 0.725, u'USD': 2.605, u'SGD': 2.575, u'CNH': 5.005, u'CNY': 0.0},
  'TOCN':{u'JPY': 0.525}}
  </code></pre>
  
  <p>margins is a pandas dataframe and can be replicated this way:</p>
  
  <pre><code>margins = pd.DataFrame([{'balance_date': '2019-06-24', 'opp_pty_cd': 'GOODM','cur': 'KRW', 'amt':9714190.0,'acct': 30}, {'balance_date': '2019-06-24', 'opp_pty_cd': 'KIS','cur': 'KRW', 'amt':1858386321.,'acct': 30}])
  </code></pre>
  
  <p>Tried the following:</p>
  
  <p>When i do this: <code>data['GOODM']['KRW']</code>, i get 0. However, when i do this: <code>data[margins['opp_pty_cd']][margins['cur']]</code>, i get this:</p>
  
  <pre><code>KRW    NaN
  KRW    NAN
  </code></pre>
  
  <p><code>margins['cur'].map(margins['opp_pty_cd'].map(data))</code>, still same data.</p>
  
  <p>I am using the data frames data to lookup the dictionaries, which doesn't work.</p>
  
  <p>Based on the comments below, tried to change the data to dataframe as <code>df_dict=pd.DataFrame.from_dict(dict)</code>. But I cant still access the data when:</p>
  
  <pre><code>data[margins['opp_pty_cd']][margins['cur']]
  </code></pre>
  
  <p>Need some guidance on this.</p>