I've tried a few tutorials on requesting and converting data from requests to pandas dataframes, however when it is converted to a pandas dataframe it shows no data. Please see below.
Attempt 1
First, check URL for a 200 status:
import requests
query = "https://data.epa.gov/efservice/PUB_DIM_FACILITY/ROWS/0:10/JSON"
response = requests.get(query)
print(response.status_code)
>>> 200
Second, check content of request. Looks good so far as there is multiple rows of data pulled from the url in JSON format.
s=requests.get(query).content
print(s)
>>> b'[{"FACILITY_ID":1000001,"LATITUDE":48.828707,"LONGITUDE":-122.685533,"CITY":"FERNDALE"
Lastly, convert s request JSON data to Pandas Dataframe.
However, this does not work.
dataframe=pd.read_csv(io.StringIO(s.decode('utf-8')), encoding='utf-8', error_bad_lines=False)
dataframe.head()
>>> 0 rows × 459 columns
Attempt 2
import pandas as pd
import io
import requests
url = 'https://data.epa.gov/efservice/PUB_DIM_FACILITY/ROWS/0:10/JSON'
r = requests.get(url)
df = pd.read_csv(io.StringIO(r.t
ext))
>>> 0 rows × 459 columns
What am I doing incorrect here? Any input would be appreciated. Thank you.