We begin by importing some helper functions
from helper import *
Now, let's get the data from the [List of helicopter prison escapes] (https://en.wikipedia.org/wiki/List_of_helicopter_prison_escapes) Wikipedia Article.
url = str('https://en.wikipedia.org/wiki/List_of_helicopter_prison_escapes')
data = data_from_url(url)
Let' print the first three rows
print(data[:3])
index = 0
for row in data:
data[index] = row[:-1]
index = index + 1
print(data[:3])
for row in data:
date = fetch_year(row[0])
row[0] = date
print(data[:3])
min_year = min(data, key=lambda x: x[0])[0]
max_year = max(data, key=lambda x: x[0])[0]
years = []
for y in range(min_year, max_year + 1):
years.append(y)
attempts_per_year = []
for y in years:
attempts_per_year.append([y, 0])
print(attempts_per_year)
for row in data:
for ya in attempts_per_year:
y = ya[0]
if row[0] == y:
ya[1] += 1
print(attempts_per_year)
%matplotlib inline
barplot(attempts_per_year)
2009, 2007, 2001 and 1986 had the most prison breaks at 3 per year
countries_frequency = df["Country"].value_counts()
print_pretty_table(countries_frequency)