Use the Folium package and our Baltimore crime dataset to make an interactive data map of Baltimore Crime.

  1. Use this piece of code to download and prepare data for use in project

!pip install folium
import folium
import requests
import pandas

arrest_table = pandas.read_csv("http://www.hcbravo.org/IntroDataSci/misc/BPD_Arrests.csv")

arrest_table["race_new"] = arrest_table["sex"]
arrest_table["sex_new"] = arrest_table["race"]
arrest_table["race"] = arrest_table["race_new"]
arrest_table["sex"] = arrest_table["sex_new"]
arrest_table = arrest_table.drop('race_new', 1)
arrest_table = arrest_table.drop('sex_new', 1)

arrest_table = arrest_table[pandas.notnull(arrest_table["Location 1"])]

arrest_table["lat"], arrest_table["long"] = arrest_table["Location 1"].str.split(",").str
arrest_table["lat"] = arrest_table["lat"].str.replace("(", "").astype(float)
arrest_table["long"] = arrest_table["long"].str.replace(")", "").astype(float)

arrest_table.head()
  1. Use the folium package to create an interactive map of Baltimore

map_osm = folium.Map(location=[39.29, -76.61], zoom_start=11)
map_osm

You can find more information about folium here: https://github.com/python-visualization/folium/ and https://folium.readthedocs.org//

  1. Add graphical elements to display the data. For instance, add circles, with colors indicating sex. Or circles with colors indicating race. Or anything else that strikes your fancy.

  2. Embed your map in your iPynb notebook and submit to ELMS.

Submission

Prepare and an iPynb notebook that includes: (a) code to carry out each of the steps above, (b) output showing the result of your code (in this case the interactive map), and (c) a short prose description of your interactive map (i.e., what are you showing with this data and map). Remember, the writeup you are preparing is intended to communicate your data analysis effectively. Thoughtlessly showing large amounts of output in your writeup defeats that purpose. This will lead nicely into your final tutorial.

Group work

Working in groups in this project is encouraged but not required. If working on a group: (1) groups can be of 2 or 3 people, and (2) in all cases, names of peers who worked in the group should be included in the writeup.

As with all group work, and reflective of academic ethics code, there is an expectation that all group members will contribute equally in design, implementation and reporting of this work. If any student feels this expectation was not met when working on this project, they should contact the instructor team who will handle the situation as expediently and fairly as possible.

Submission

Submit to ELMS here: https://myelms.umd.edu/courses/1218364/assignments/4389211. (The submission file type on ELMS is set to .ipynb ...)

Web Accessibility