Federal, state, and local governments have started making more of their data publicly available. This is part of the so-called open data movement. Application Programming Interfaces (APIs), which many institutions have begun supporting, allow researchers and other individuals interested in working with and analyzing data to access information, often large amounts of it, programmatically.
DataSF is the open data portal for the city (and county) of San Francisco.
For this project, I accessed incident reports from the San Francisco Police Department (SFPD), focusing on traffic-related entries. I extracted the data using the requests module in Python and loaded resulting the JSON data in a pandas DataFrame. I plotted the data using the Seaborn library and created a Leaflet map with the traffic incidents for three months, September through November 2014. The IPython Notebook with the code used to process the data is provided.