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]:
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()