Now You Code 2: Arrests by State

You are now finished with college and doing some research on where to apply for a job. Workng in a safe state would be a great start.

Scrape the FBI arrest by state table provided on ucr.fbi.gov. The table is available at the link below.

https://ucr.fbi.gov/crime-in-the-u.s/2015/crime-in-the-u.s.-2015/tables/table-69

Suggested Approach:

  • Download the html using the requests library.
  • Extract the data using BeautifulSoup from the table using. Make sure you use functions that extract each part of the data.
  • Build a pandas dataframe containing the data. To make things a little easier, use Total all ages for each state.
  • Create a bar chart displaying the state and total arrests.

Sample Output:


In [ ]:
import requests
from bs4 import BeautifulSoup
import matplotlib.pyplot as plt
import pandas as pd
%matplotlib notebook
plt.rcParams["figure.figsize"] = [12, 6]

In [ ]: