Skip to content

Instantly share code, notes, and snippets.

@andersonfrailey
Last active January 25, 2018 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andersonfrailey/86c323414309e1d84ad897a512c7dfd9 to your computer and use it in GitHub Desktop.
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 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