title: How to append a dictionary to a pandas dataframe?
body: <p>I have a set of urls containing json files and an empty pandas dataframe with columns representing the attributes of the jsnon files. Not all json files have all the attributes in the pandas dataframe. What I need to do is to create dictionaries out of the json files and then append each dictionary to the pandas dataframe as a new row and, in case the json file doesn't have an attribute matching a column in the dataframe this has to be filled blank.</p>
  
  <p>I managed to create dictionaries as:</p>
  
  <pre><code>import urllib2
  import json  
  
  url = "https://cws01.worldstores.co.uk/api/product.php?product_sku=ULST:7BIS01CF"
  data = urllib2.urlopen(url).read()
  data = json.loads(data)
  </code></pre>
  
  <p>and then I tried to create a for loop as follows:</p>
  
  <pre><code>row = -1
  for i in links:
      row = row + 1
      data = urllib2.urlopen(str(i)).read()
      data = json.loads(data)
      for key in data.keys():
          for column in df.columns:
              if str(column) == str(key):
                  df.loc[[str(column)],row] = data[str(key)]
              else:
                  df.loc[[str(column)],row] = None
  </code></pre>
  
  <p>where df is the dataframe and links is the set of urls</p>
  
  <p>However,  I get the following error:</p>
  
  <pre><code>raise KeyError('%s not in index' % objarr[mask])
  
  KeyError: "['2_seater_depth_mm'] not in index"
  </code></pre>
  
  <p>where ['2_seater_depth_mm'] is the first column of the pandas dataframe</p>