Web APIs are now a common way to interact with data, and many governments now have open data portals that offer access via API. Socrata is a common vendor.
Here, we're going to tap into the API feed of a dataset of vacant buildings in St. Paul.
In [ ]:
In [ ]:
# URL
# use the json() method, which converts the json into Python objects
# print to see what we're working with
Looks like we're dealing with a list of dictionaries. Maybe our goal here is to filter out everything except the vacant single-family residences.
Let's use a new thing called a list comprehension -- really handy when you want to filter a group of things and store the result in a variable.
In [ ]:
From the original data set, filter out everything except vacant buildings that were vacant as of (vacant_as_of) 2013 or later. Select whatever elements of the data are interesting to you and write out to a CSV file.
Breaking down the problem:
In [ ]: