from helper import *
url = 'https://en.wikipedia.org/wiki/List_of_helicopter_prison_escapes'
data = data_from_url(url)
print(data[0][0])
August 19, 1971
index=0
for row in data:
row = row[:5]
data[index] = row
index +=1
for row in data:
year = fetch_year(str(row[0]))
row[0]=year
print(data[:3])
[[1971, 'Santa Martha Acatitla', 'Mexico', 'Yes', 'Joel David Kaplan Carlos Antonio Contreras Castro'], [1973, 'Mountjoy Jail', 'Ireland', 'Yes', "JB O'Hagan Seamus TwomeyKevin Mallon"], [1978, 'United States Penitentiary, Marion', 'United States', 'No', 'Garrett Brock TrapnellMartin Joseph McNallyJames Kenneth Johnson']]
new_data=[]
for row in data: new_data.append(row[0]) print(new_data)
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)
1971 2020
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)
[[1971, 0], [1972, 0], [1973, 0], [1974, 0], [1975, 0], [1976, 0], [1977, 0], [1978, 0], [1979, 0], [1980, 0], [1981, 0], [1982, 0], [1983, 0], [1984, 0], [1985, 0], [1986, 0], [1987, 0], [1988, 0], [1989, 0], [1990, 0], [1991, 0], [1992, 0], [1993, 0], [1994, 0], [1995, 0], [1996, 0], [1997, 0], [1998, 0], [1999, 0], [2000, 0], [2001, 0], [2002, 0], [2003, 0], [2004, 0], [2005, 0], [2006, 0], [2007, 0], [2008, 0], [2009, 0], [2010, 0], [2011, 0], [2012, 0], [2013, 0], [2014, 0], [2015, 0], [2016, 0], [2017, 0], [2018, 0], [2019, 0], [2020, 0]]
for row in data:
for ya in attempts_per_year:
if ya[0] == row[0]:
ya[1]+=1
print(attempts_per_year)
[[1971, 3], [1972, 0], [1973, 3], [1974, 0], [1975, 0], [1976, 0], [1977, 0], [1978, 3], [1979, 0], [1980, 0], [1981, 6], [1982, 0], [1983, 3], [1984, 0], [1985, 6], [1986, 9], [1987, 3], [1988, 3], [1989, 6], [1990, 3], [1991, 3], [1992, 6], [1993, 3], [1994, 0], [1995, 0], [1996, 3], [1997, 3], [1998, 0], [1999, 3], [2000, 6], [2001, 9], [2002, 6], [2003, 3], [2004, 0], [2005, 6], [2006, 3], [2007, 9], [2008, 0], [2009, 9], [2010, 3], [2011, 0], [2012, 3], [2013, 6], [2014, 3], [2015, 0], [2016, 3], [2017, 0], [2018, 3], [2019, 0], [2020, 3]]
%matplotlib inline
barplot(attempts_per_year)
countries_frequency = df["Country"].value_counts()
print(countries_frequency)
France 15 United States 8 Belgium 4 Canada 4 Greece 4 Brazil 2 United Kingdom 2 Australia 2 Netherlands 1 Puerto Rico 1 Italy 1 Ireland 1 Russia 1 Chile 1 Mexico 1 Name: Country, dtype: int64
print_pretty_table(countries_frequency)
Country | Number of Occurrences |
---|---|
France | 15 |
United States | 8 |
Belgium | 4 |
Canada | 4 |
Greece | 4 |
Brazil | 2 |
United Kingdom | 2 |
Australia | 2 |
Netherlands | 1 |
Puerto Rico | 1 |
Italy | 1 |
Ireland | 1 |
Russia | 1 |
Chile | 1 |
Mexico | 1 |