In [121]:
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import requests

In [122]:
url = 'http://www.NflArrest.com/api/v1/team'
req = requests.get(url)
json = req.json()

teams = pd.DataFrame(json)

In [123]:
# show the head of the data frame.
teams.head()


Out[123]:
Team Team_Conference Team_Conference_Division Team_city Team_logo_id Team_name Team_preffered_name arrest_count
0 MIN NFC NFC North Minneapolis 18 Vikings Minnesota Vikings 49
1 DEN AFC AFC West Denver 10 Broncos Denver Broncos 48
2 CIN AFC AFC North Cincinnati 7 Bengals Cincinnati Bengals 44
3 TB NFC NFC South Tampa Bay 30 Buccaneers Tampa Bay Buccaneers 36
4 JAC AFC AFC South Jacksonville 15 Jaguars Jacksonville Jaguars 36

In [124]:
# convert arrest_count from str to int.
teams['arrest_count'] = teams['arrest_count'].apply(lambda v: int(v))

In [125]:
# create bar plot of teams to number of arrests.
teams[['Team','arrest_count']].plot.bar(x='Team',figsize=(20,20),legend=False)

plt.title('Arrests by NFL Team')
plt.xlabel('Teams')
plt.ylabel('Arrests')
plt.show()