Last active
January 25, 2018 14:20
-
-
Save andersonfrailey/86c323414309e1d84ad897a512c7dfd9 to your computer and use it in GitHub Desktop.
Places a call to the Code for DC Homeless Servaces Facilities data base and puts it in a Pandas DataFrame
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This script retreaves information on homeless services facilities from | |
http://opendata.dc.gov/datasets/homeless-service-facilities | |
""" | |
import requests | |
import pandas as pd | |
api_url = 'https://maps2.dcgis.dc.gov/dcgis/rest/services/DCGIS_DATA/Public_Service_WebMercator/MapServer/6/query?where=1%3D1&outFields=*&outSR=4326&f=json' | |
raw_data = requests.get(api_url) | |
# the api call returns a list of dictionaries. Each dictionary has a | |
# key 'attributes' that contains the information for each facility | |
data_list = [item['attributes'] for item in raw_data.json()['features']] | |
data_df = pd.DataFrame(data_list) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment