title: python: Getting error when importing type requests.models.Response into dataframe
body: <p>I'm new to python and I'm trying to use the census geocoding services API to geocode addresses then convert the output to a dataframe. I've been able to read in my address file and I can see the output, but I can't seem to figure out how to import it into a dataframe. I provided the code I used below as well as the contents of the address file.</p>
  <p>The output does not appear to be in JSON format, but rather CSV. I tried to import the output as I would a CSV file, but I couldn't figure out how to import the variable as I would a CSV file and I couldn't figure out how to export the output to a CSV file that I could import.</p>
  <p>The URL describing the API is <a href="https://geocoding.geo.census.gov/geocode...es_API.pdf" rel="nofollow noreferrer">https://geocoding.geo.census.gov/geocode...es_API.pdf</a></p>
  <pre><code>import requests
  import pandas as pd
  import json
  url = 'https://geocoding.geo.census.gov/geocoder/geographies/addressbatch'
  payload = {'benchmark':'Public_AR_Current','vintage':'Current_Current'}
  files = {'addressFile': ('C:\PYTHON_CLASS\CSV\ADDRESS_SAMPLE.csv', open('C:\PYTHON_CLASS\CSV\ADDRESS_SAMPLE.csv', 'rb'), 'text/csv')}
  response = requests.post(url, files=files, data = payload)
  type(response)
  print(response.text)
  </code></pre>
  <p>-I tried the code below (among many other versions) which is how I would normally import a CSV file, but it generates an error message &quot;Invalid file path or buffer object type: &lt;class 'requests.models.Response'&gt;&quot;</p>
  <pre><code>df = pd.read_csv(response)
  </code></pre>
  <p>The contents of the address file I used to generate the geocoding is:</p>
  <p>id,address,city,state,zipcode
  1,1600 Pennsylvania Avenue NW, Washington,DC,20500
  2,4 S Market St,Boston,MA,02109
  3,1200 Getty Center Drive,Los Angeles,CA,90049
  4,1800 Congress Ave,Austin,TX,78701
  5,One Caesars Palace Drive,Las Vegas,NV,89109
  6,1060 West Addison,Chicago,IL,60613
  7,One East 161st Street,Bronx,NY,10451
  8,201 E Jefferson St,Phoenix,AZ,85004
  9,600 N 1st Ave,Minneapolis,MN,55403
  10,400 W Church St,Orlando,FL,32801</p>
  <p>The output is shown below:</p>
  <pre><code>print(response.text)
  </code></pre>
  <p>&quot;1&quot;,&quot;1600 Pennsylvania Avenue NW,  Washington, DC, 20500&quot;,&quot;Match&quot;,&quot;Non_Exact&quot;,&quot;1600 PENNSYLVANIA AVE NW, WASHINGTON, DC, 20006&quot;,&quot;-77.03535,38.898754&quot;,&quot;76225813&quot;,&quot;L&quot;,&quot;11&quot;,&quot;001&quot;,&quot;006202&quot;,&quot;1031&quot;
  &quot;2&quot;,&quot;4 S Market St, Boston, MA, 02109&quot;,&quot;Match&quot;,&quot;Exact&quot;,&quot;4 S MARKET ST, BOSTON, MA, 02109&quot;,&quot;-71.05566,42.359936&quot;,&quot;85723841&quot;,&quot;R&quot;,&quot;25&quot;,&quot;025&quot;,&quot;030300&quot;,&quot;2017&quot;
  &quot;3&quot;,&quot;1200 Getty Center Drive, Los Angeles, CA, 90049&quot;,&quot;Match&quot;,&quot;Exact&quot;,&quot;1200 GETTY CENTER DR, LOS ANGELES, CA, 90049&quot;,&quot;-118.47564,34.08857&quot;,&quot;142816014&quot;,&quot;L&quot;,&quot;06&quot;,&quot;037&quot;,&quot;262302&quot;,&quot;1005&quot;
  &quot;4&quot;,&quot;1800 Congress Ave, Austin, TX, 78701&quot;,&quot;Match&quot;,&quot;Exact&quot;,&quot;1800 CONGRESS AVE, AUSTIN, TX, 78701&quot;,&quot;-97.73847,30.279745&quot;,&quot;63946318&quot;,&quot;L&quot;,&quot;48&quot;,&quot;453&quot;,&quot;000700&quot;,&quot;1007&quot;
  &quot;5&quot;,&quot;One Caesars Palace Drive, Las Vegas, NV, 89109&quot;,&quot;No_Match&quot;
  &quot;6&quot;,&quot;1060 West Addison, Chicago, IL, 60613&quot;,&quot;Match&quot;,&quot;Non_Exact&quot;,&quot;1060 W ADDISON ST, CHICAGO, IL, 60613&quot;,&quot;-87.65581,41.947227&quot;,&quot;111863716&quot;,&quot;R&quot;,&quot;17&quot;,&quot;031&quot;,&quot;061100&quot;,&quot;1014&quot;
  &quot;7&quot;,&quot;One East 161st Street, Bronx, NY, 10451&quot;,&quot;No_Match&quot;
  &quot;8&quot;,&quot;201 E Jefferson St, Phoenix, AZ, 85004&quot;,&quot;Match&quot;,&quot;Exact&quot;,&quot;201 E JEFFERSON ST, PHOENIX, AZ, 85004&quot;,&quot;-112.07113,33.44675&quot;,&quot;128300920&quot;,&quot;L&quot;,&quot;04&quot;,&quot;013&quot;,&quot;114100&quot;,&quot;1058&quot;
  &quot;9&quot;,&quot;600 N 1st Ave, Minneapolis, MN, 55403&quot;,&quot;No_Match&quot;
  &quot;id&quot;,&quot;address, city, state, zipcode&quot;,&quot;No_Match&quot;
  &quot;10&quot;,&quot;400 W Church St, Orlando, FL, 32801&quot;,&quot;Match&quot;,&quot;Exact&quot;,&quot;400 W CHURCH ST, ORLANDO, FL, 32801&quot;,&quot;-81.38436,28.540176&quot;,&quot;94416807&quot;,&quot;L&quot;,&quot;12&quot;,&quot;095&quot;,&quot;010500&quot;,&quot;1002&quot;</p>
  <p>The output for <code>response.text</code> is:</p>
  <p>'&quot;1&quot;,&quot;1600 Pennsylvania Avenue NW,  Washington, DC, 20500&quot;,&quot;Match&quot;,&quot;Non_Exact&quot;,&quot;1600 PENNSYLVANIA AVE NW, WASHINGTON, DC, 20006&quot;,&quot;-77.03535,38.898754&quot;,&quot;76225813&quot;,&quot;L&quot;,&quot;11&quot;,&quot;001&quot;,&quot;006202&quot;,&quot;1031&quot;\n&quot;2&quot;,&quot;4 S Market St, Boston, MA, 02109&quot;,&quot;Match&quot;,&quot;Exact&quot;,&quot;4 S MARKET ST, BOSTON, MA, 02109&quot;,&quot;-71.05566,42.359936&quot;,&quot;85723841&quot;,&quot;R&quot;,&quot;25&quot;,&quot;025&quot;,&quot;030300&quot;,&quot;2017&quot;\n&quot;3&quot;,&quot;1200 Getty Center Drive, Los Angeles, CA, 90049&quot;,&quot;Match&quot;,&quot;Exact&quot;,&quot;1200 GETTY CENTER DR, LOS ANGELES, CA, 90049&quot;,&quot;-118.47564,34.08857&quot;,&quot;142816014&quot;,&quot;L&quot;,&quot;06&quot;,&quot;037&quot;,&quot;262302&quot;,&quot;1005&quot;\n&quot;4&quot;,&quot;1800 Congress Ave, Austin, TX, 78701&quot;,&quot;Match&quot;,&quot;Exact&quot;,&quot;1800 CONGRESS AVE, AUSTIN, TX, 78701&quot;,&quot;-97.73847,30.279745&quot;,&quot;63946318&quot;,&quot;L&quot;,&quot;48&quot;,&quot;453&quot;,&quot;000700&quot;,&quot;1007&quot;\n&quot;5&quot;,&quot;One Caesars Palace Drive, Las Vegas, NV, 89109&quot;,&quot;No_Match&quot;\n&quot;6&quot;,&quot;1060 West Addison, Chicago, IL, 60613&quot;,&quot;Match&quot;,&quot;Non_Exact&quot;,&quot;1060 W ADDISON ST, CHICAGO, IL, 60613&quot;,&quot;-87.65581,41.947227&quot;,&quot;111863716&quot;,&quot;R&quot;,&quot;17&quot;,&quot;031&quot;,&quot;061100&quot;,&quot;1014&quot;\n&quot;7&quot;,&quot;One East 161st Street, Bronx, NY, 10451&quot;,&quot;No_Match&quot;\n&quot;8&quot;,&quot;201 E Jefferson St, Phoenix, AZ, 85004&quot;,&quot;Match&quot;,&quot;Exact&quot;,&quot;201 E JEFFERSON ST, PHOENIX, AZ, 85004&quot;,&quot;-112.07113,33.44675&quot;,&quot;128300920&quot;,&quot;L&quot;,&quot;04&quot;,&quot;013&quot;,&quot;114100&quot;,&quot;1058&quot;\n&quot;9&quot;,&quot;600 N 1st Ave, Minneapolis, MN, 55403&quot;,&quot;No_Match&quot;\n&quot;id&quot;,&quot;address, city, state, zipcode&quot;,&quot;No_Match&quot;\n&quot;10&quot;,&quot;400 W Church St, Orlando, FL, 32801&quot;,&quot;Match&quot;,&quot;Exact&quot;,&quot;400 W CHURCH ST, ORLANDO, FL, 32801&quot;,&quot;-81.38436,28.540176&quot;,&quot;94416807&quot;,&quot;L&quot;,&quot;12&quot;,&quot;095&quot;,&quot;010500&quot;,&quot;1002&quot;\n'</p>
  <p>When I tried</p>
  <pre><code>df = pd.read_csv(io.StringIO(response), sep=',', header=None, quoting=csv.QUOTE_ALL)
  </code></pre>
  <p>I got the error message</p>
  <pre><code>TypeError                                 Traceback (most recent call last)
  &lt;ipython-input-60-55e6c5ac54af&gt; in &lt;module&gt;
  ----&gt; 1 df = pd.read_csv(io.StringIO(response), sep=',', header=None, quoting=csv.QUOTE_ALL)
  
  TypeError: initial_value must be str or None, not Response
  </code></pre>
  <p>When I tried</p>
  <pre><code>df = pd.read_csv(io.StringIO(response.replace('&quot; &quot;', '&quot;\n&quot;')), sep=',', header=None, quoting=csv.QUOTE_ALL)
  </code></pre>
  <p>I got</p>
  <pre><code>AttributeError                            Traceback (most recent call last)
  &lt;ipython-input-61-a92a7ffcf170&gt; in &lt;module&gt;
  ----&gt; 1 df = pd.read_csv(io.StringIO(response.replace('&quot; &quot;', '&quot;\n&quot;')), sep=',', header=None, quoting=csv.QUOTE_ALL)
  
  AttributeError: 'Response' object has no attribute 'replace'
  </code></pre>