title: How to solve "TypeError: expected string or buffer" when importing json data via api?
body: <p>I'm trying to import JSON data via an API, and use the imported data to construct a DataFrame. </p>
  
  <pre><code>import json
  import pandas as pd
  import numpy as np
  import requests
  
  api_username = 'acb'
  api_password = 'efg'
  
  germany_name = 'Germany'
  germany_api_url = "https://api.country_data.com/stats/?country=" + germany_name + "&amp;year=2014"
  germany_api_resp = requests.get(germany_api_url,auth=(api_username,api_password))
  germany_data_json = json.loads(germany_api_resp)
  germany_frame = pd.DataFrame(germany_data_json['data']).set_index('tag')
  </code></pre>
  
  <p><code>print(germany_frame)</code> shows me the desired DataFrame.</p>
  
  <p>I want to repeat the process for many countries, not just <code>'Germany'</code>, so I created a country object like this:</p>
  
  <pre><code>class Country(object):
      def __init__(self,name):
          self.name = name
          self.api_url = "https://api.country_data.com/stats/?country=" + name + "&amp;year=2014"
          self.api_resp = requests.get(self.api_url,auth=(api_username,api_password))
          self.data_json = json.loads(self.api_resp)
          self.frame = pd.DataFrame(self.data_json['data']).set_index('tag')
  </code></pre>
  
  <p>When I create my first object, like this:</p>
  
  <pre><code>Germany = Country('Germany')
  </code></pre>
  
  <p>I get an Error message:</p>
  
  <pre><code>TypeError: expected string or buffer
  </code></pre>
  
  <p>Can someone help me with this issue?</p>