# Analyzing Data
# Prison Helicopter Escapes
# We begin by importing some helper functions.
from helper import *
# Get the Data
# 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 = "https://en.wikipedia.org/wiki/List_of_helicopter_prison_escapes"
data = data_from_url(url)
# Let's print the first three rows
for row in data[1:4]:
print(row)
['October 31, 1973', 'Mountjoy Jail', 'Ireland', 'Yes', "JB O'Hagan Seamus TwomeyKevin Mallon", 'On October 31, 1973 an IRA member hijacked a helicopter and forced the pilot to land in the exercise yard of Dublin\'s Mountjoy Jail\'s D Wing at 3:40\xa0p.m., October 31, 1973. Three members of the IRA were able to escape: JB O\'Hagan, Seamus Twomey and Kevin Mallon. Another prisoner who also was in the prison was quoted as saying, "One shamefaced screw apologised to the governor and said he thought it was the new Minister for Defence (Paddy Donegan) arriving. I told him it was our Minister of Defence leaving." The Mountjoy helicopter escape became Republican lore and was immortalized by "The Helicopter Song", which contains the lines "It\'s up like a bird and over the city. There\'s three men a\'missing I heard the warder say".[1]'] ['May 24, 1978', 'United States Penitentiary, Marion', 'United States', 'No', 'Garrett Brock TrapnellMartin Joseph McNallyJames Kenneth Johnson', "43-year-old Barbara Ann Oswald hijacked a Saint Louis-based charter helicopter and forced the pilot to land in the yard at USP Marion. While landing the aircraft, the pilot, Allen Barklage, who was a Vietnam War veteran, struggled with Oswald and managed to wrestle the gun away from her. Barklage then shot and killed Oswald, thwarting the escape.[10] A few months later Oswald's daughter hijacked TWA Flight 541 in an effort to free Trapnell."] ['February 27, 1981', 'Fleury-Mérogis, Essonne, Ile de France', 'France', 'Yes', 'Gérard DupréDaniel Beaumont', "With the help of Serge Coutel, Gérard Dupré and Daniel Beaumont, succeed in the first and double helicopter escape of a French prison, in Fleury-Mérogis (Essonne), the best kept prison of France. The men hijacked a helicopter and its pilot that they rented to fly from Paris to Orléans. The pilot, Claude Fourcade, was taken hostage and was told that they were holding his wife and daughter hostage (which was not true) ... The flight turned into Paris - Fleury -Merogis - Porte d'Orléans.[11]"]
index = 0
for row in data:
data[index] = row[0:4]
index += 1
for row in data[0:4]:
print(row)
['September 25, 2020', 'Forest prison, Brussels', 'Belgium', 'No'] ['October 31, 1973', 'Mountjoy Jail', 'Ireland', 'Yes'] ['May 24, 1978', 'United States Penitentiary, Marion', 'United States', 'No'] ['February 27, 1981', 'Fleury-Mérogis, Essonne, Ile de France', 'France', 'Yes']
index = 0
for row in data:
row[0] = fetch_year(row[0])
index += 1
for row in data[0:4]:
print(row)
[2020, 'Forest prison, Brussels', 'Belgium', 'No'] [1973, 'Mountjoy Jail', 'Ireland', 'Yes'] [1978, 'United States Penitentiary, Marion', 'United States', 'No'] [1981, 'Fleury-Mérogis, Essonne, Ile de France', 'France', 'Yes']
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 = []
count = 0
item = []
for y in years:
for row in data:
if y == row[0]:
count += 1
item = y, count
attempts_per_year.append(item)
print(attempts_per_year)
[(1973, 1), (1974, 1), (1975, 1), (1976, 1), (1977, 1), (1978, 2), (1979, 2), (1980, 2), (1981, 4), (1982, 4), (1983, 5), (1984, 5), (1985, 7), (1986, 10), (1987, 11), (1988, 12), (1989, 14), (1990, 15), (1991, 16), (1992, 18), (1993, 19), (1994, 19), (1995, 19), (1996, 20), (1997, 21), (1998, 21), (1999, 22), (2000, 24), (2001, 27), (2002, 29), (2003, 30), (2004, 30), (2005, 32), (2006, 33), (2007, 36), (2008, 36), (2009, 39), (2010, 40), (2011, 40), (2012, 41), (2013, 43), (2014, 44), (2015, 44), (2016, 45), (2017, 45), (2018, 46), (2019, 46), (2020, 48)]
%matplotlib inline
barplot(attempts_per_year)
countries_frequency = df["Country"].value_counts()
print_pretty_table(countries_frequency)
Country | Number of Occurrences |
---|---|
France | 15 |
United States | 8 |
Greece | 4 |
Canada | 4 |
Belgium | 4 |
Australia | 2 |
United Kingdom | 2 |
Brazil | 2 |
Italy | 1 |
Netherlands | 1 |
Puerto Rico | 1 |
Chile | 1 |
Mexico | 1 |
Ireland | 1 |
Russia | 1 |