"We begin by importing some helper functions"
from helper import *
url = 'https://en.wikipedia.org/wiki/List_of_helicopter_prison_escapes'
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.
data = data_from_url(url)
for row in data[:3]:
print(row)
Let's print the first three rows
index = 0
for row in data:
data[index] = row[:-1]
index = index + 1
print(data[0])
for row in data:
row[0] = fetch_year(row[0])
print(data[0])
min_year = min(data, key=lambda x: x[0])[0]
max_year = max(data, key=lambda x: x[0])[0]
print(min_year)
print(max_year)
years = []
for y in range(min_year, max_year + 1):
years.append(y)
print(years)
attempts_per_year = []
for row in years:
pp = [row,0]
attempts_per_year.append(pp)
print(attempts_per_year)
# Instruction 1 - for each row in data
for row in data:
for ya in attempts_per_year: # Instruction 2 - nothing to do here
# Instruction 3 - assign the year value in ya to y
if row[0] == ya[0]:
ya[1] += 1
# Instruction 4 - print the results
print(attempts_per_year)
%matplotlib inline
barplot(attempts_per_year)
In which year did the most attempts at breaking out of prison with a helicopter occur? 2009,2007,2001,1986
countries_frequency = df["Country"].value_counts()