We begin by importing some helper functions
from helper import *
Now, let's get the data from the 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[:3]:
print(row)
['August 19, 1971', 'Santa Martha Acatitla', 'Mexico', 'Yes', 'Joel David Kaplan Carlos Antonio Contreras Castro', "Joel David Kaplan was a New York businessman who had been arrested for murder in 1962 in Mexico City and was incarcerated at the Santa Martha Acatitla prison in the Iztapalapa borough of Mexico City. Joel's sister, Judy Kaplan, arranged the means to help Kaplan escape, and on August 19, 1971, a helicopter landed in the prison yard. The guards mistakenly thought this was an official visit. In two minutes, Kaplan and his cellmate Carlos Antonio Contreras, a Venezuelan counterfeiter, were able to board the craft and were piloted away, before any shots were fired.[9] Both men were flown to Texas and then different planes flew Kaplan to California and Contreras to Guatemala.[3] The Mexican government never initiated extradition proceedings against Kaplan.[9] The escape is told in a book, The 10-Second Jailbreak: The Helicopter Escape of Joel David Kaplan.[4] It also inspired the 1975 action movie Breakout, which starred Charles Bronson and Robert Duvall.[9]"] ['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."]
index = 0
for row in data:
data[index] = row[:-1]
index += 1
# To see the result, print data
print(data)
[['August 19, 1971', 'Santa Martha Acatitla', 'Mexico', 'Yes', 'Joel David Kaplan Carlos Antonio Contreras Castro'], ['October 31, 1973', 'Mountjoy Jail', 'Ireland', 'Yes', "JB O'Hagan Seamus TwomeyKevin Mallon"], ['May 24, 1978', 'United States Penitentiary, Marion', 'United States', 'No', 'Garrett Brock TrapnellMartin Joseph McNallyJames Kenneth Johnson'], ['February 27, 1981', 'Fleury-Mérogis, Essonne, Ile de France', 'France', 'Yes', 'Gérard DupréDaniel Beaumont'], ['May 7, 1981', 'Orsainville Prison, Quebec City', 'Canada', 'No', 'Marina Paquet (hijacker)Giles Arseneault (prisoner)'], ['January, 1983', 'Pentridge (HM Prison)', 'Australia', 'No', 'David McMillan'], ['December 19, 1985', 'Perry Correctional Institution, Pelzer, South Carolina', 'United States', 'Yes', 'James Rodney LeonardWilliam Douglas BallewJesse Glenn Smith'], ['December 31, 1985', 'Cândido Mendes penitentiary, Ilha Grande, Rio de Janeiro', 'Brazil', 'Yes', 'José Carlos dos Reis Encina, a.k.a. "Escadinha"'], ['May 26, 1986', 'Prison de la Santé', 'France', 'Yes', 'Michel Vaujour'], ['November 5, 1986', 'Federal Correctional Institution, Dublin', 'United States', 'Yes', 'Samantha Lopez'], ['November 23, 1986', 'Prigione di Rebibbia, Roma', 'Italy', 'Yes', 'André BellaïcheGianluigi EspositoLuciano Cipollari'], ['December 10, 1987', 'Gartree (HM Prison)', 'United Kingdom', 'Yes', 'Sydney DraperJohn Kendall'], ['July 11, 1988', 'Santa Fe prison', 'United States', 'Yes', 'Mahoney Danny Francis MitchellRandy Lackey'], ['April 17, 1989', 'Federal Holding Facility, Miami, FL', 'United States', 'No', 'Ben Kramer'], ['August 19, 1989', 'Arkansas Valley Correctional Facility', 'United States', 'Yes', 'Ralph BrownFreddie Gonzales'], ['June 19, 1990', 'Kent Penitentiary, British Columbia', 'Canada', 'Yes', 'Robert FordDavid Thomas'], ['April 7, 1991', 'Rio Piedras State Penitentiary, Puerto Rico', 'Puerto Rico', 'Yes', 'William Lane'], ['February 24, 1992', 'Lyon Prison', 'France', 'Yes', '—'], ['December 1992', 'Touraine Central Prison, Tours', 'France', 'No', '—'], ['June 17, 1993', 'Touraine Central Prison, Tours', 'France', 'No', 'Michel Vaujour'], ['December 30, 1996', 'High Security Prison, Santiago', 'Chile', 'Yes', 'Four members of the Manuel Rodriguez Patriotic Front'], ['September 18, 1997', 'De Geerhorst jail', 'Netherlands', 'No', '—'], ['March 25, 1999', 'Metropolitan Remand and Reception Centre', 'Australia', 'Yes', 'John Killick'], ['June 5, 2000', 'Martin Treatment Center for Sexually Violent Predators, Martin County Florida', 'United States', 'Yes', 'Steven Whitsett'], ['December 13, 2000', 'Lyon prison', 'France', 'Yes', '—'], ['January 19, 2001', 'Luynes prison', 'France', 'Yes', 'Pascal Payet'], ['March 24, 2001', 'Draguignan prison', 'France', 'Yes', 'Abdelhamid CarnousEmile Forma-SariJean-Philippe Lecase'], ['May 28, 2001', 'Fresnes prison', 'France', 'No', '—'], ['January 17, 2002', 'Parada Neto Penitentiary', 'Brazil', 'Yes', '—'], ['December 30, 2002', 'Las Cucharas prison, Puerto Rico', 'United States', 'Yes', 'Orlando Cartagena Jose Rodriguez Victor Diaz Hector Diaz Jose Tapia'], ['April 4, 2003', 'Luynes prison', 'France', 'Yes', 'Eric AlboreoFranck PerlettoMichel Valero'], ['July 2005', 'France', 'France', 'No', '—'], ['December 10, 2005', 'Aiton Prison', 'France', 'Yes', 'Hubert SellesJean-Claude MorettiMohamed Bessame'], ['June 6, 2006', 'Korydallos Prison', 'Greece', 'Yes', 'Vassilis Paleokostas'], ['April 15, 2007', 'Lantin Prison, Liège', 'Belgium', 'Yes', 'Eric Ferdinand'], ['July 15, 2007', 'Grasse prison', 'France', 'Yes', 'Pascal Payet'], ['October 28, 2007', 'Ittre prison', 'Belgium', 'No', 'Nordin Benallal'], ['February 22, 2009', 'Korydallos Prison', 'Greece', 'Yes', 'Vasilis PaleokostasAlket Rizai'], ['April 27, 2009', 'Domenjod Prison, Réunion', 'France', 'Yes', 'Alexin JismyFabrice Michel'], ['July 23, 2009', 'Bruges', 'Belgium', 'Yes', 'Ashraf Sekkaki plus three other criminals'], ['June 25, 2010', 'HM Prison Isle of Wight, Isle of Wight', 'United Kingdom', 'No', 'Brian Lawrence'], ['March 22, 2012', 'Sheksna, Penal colony N17', 'Russia', 'Yes', 'Alexey Shestakov'], ['February 24, 2013', 'Trikala Prison, Trikala', 'Greece', 'No', 'Panagiotis Vlastos'], ['March 17, 2013', 'Saint-Jérôme Detention Facility, Quebec', 'Canada', 'Yes', 'Benjamin Hudon-BarbeauDanny Provençal'], ['June 7, 2014', 'Orsainville Detention Facility, Quebec', 'Canada', 'Yes', 'Yves DenisDenis LefebvreSerge Pomerleau'], ['February 22, 2016', 'Thiva', 'Greece', 'No', 'Pola RoupaNikos Maziotis'], ['July 1, 2018', 'Réau, near Paris', 'France', 'Yes', 'Rédoine Faïd'], ['September 25, 2020', 'Forest prison, Brussels', 'Belgium', 'No', 'Kristel A.']]
Modifying the data column to only include the year, using the helper function fetch_year()
for row in data:
row[0] = fetch_year(row[0])
To confirm that the task was executed correctly, I shall print out the data
print(data)
[[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'], [1981, 'Fleury-Mérogis, Essonne, Ile de France', 'France', 'Yes', 'Gérard DupréDaniel Beaumont'], [1981, 'Orsainville Prison, Quebec City', 'Canada', 'No', 'Marina Paquet (hijacker)Giles Arseneault (prisoner)'], [1983, 'Pentridge (HM Prison)', 'Australia', 'No', 'David McMillan'], [1985, 'Perry Correctional Institution, Pelzer, South Carolina', 'United States', 'Yes', 'James Rodney LeonardWilliam Douglas BallewJesse Glenn Smith'], [1985, 'Cândido Mendes penitentiary, Ilha Grande, Rio de Janeiro', 'Brazil', 'Yes', 'José Carlos dos Reis Encina, a.k.a. "Escadinha"'], [1986, 'Prison de la Santé', 'France', 'Yes', 'Michel Vaujour'], [1986, 'Federal Correctional Institution, Dublin', 'United States', 'Yes', 'Samantha Lopez'], [1986, 'Prigione di Rebibbia, Roma', 'Italy', 'Yes', 'André BellaïcheGianluigi EspositoLuciano Cipollari'], [1987, 'Gartree (HM Prison)', 'United Kingdom', 'Yes', 'Sydney DraperJohn Kendall'], [1988, 'Santa Fe prison', 'United States', 'Yes', 'Mahoney Danny Francis MitchellRandy Lackey'], [1989, 'Federal Holding Facility, Miami, FL', 'United States', 'No', 'Ben Kramer'], [1989, 'Arkansas Valley Correctional Facility', 'United States', 'Yes', 'Ralph BrownFreddie Gonzales'], [1990, 'Kent Penitentiary, British Columbia', 'Canada', 'Yes', 'Robert FordDavid Thomas'], [1991, 'Rio Piedras State Penitentiary, Puerto Rico', 'Puerto Rico', 'Yes', 'William Lane'], [1992, 'Lyon Prison', 'France', 'Yes', '—'], [1992, 'Touraine Central Prison, Tours', 'France', 'No', '—'], [1993, 'Touraine Central Prison, Tours', 'France', 'No', 'Michel Vaujour'], [1996, 'High Security Prison, Santiago', 'Chile', 'Yes', 'Four members of the Manuel Rodriguez Patriotic Front'], [1997, 'De Geerhorst jail', 'Netherlands', 'No', '—'], [1999, 'Metropolitan Remand and Reception Centre', 'Australia', 'Yes', 'John Killick'], [2000, 'Martin Treatment Center for Sexually Violent Predators, Martin County Florida', 'United States', 'Yes', 'Steven Whitsett'], [2000, 'Lyon prison', 'France', 'Yes', '—'], [2001, 'Luynes prison', 'France', 'Yes', 'Pascal Payet'], [2001, 'Draguignan prison', 'France', 'Yes', 'Abdelhamid CarnousEmile Forma-SariJean-Philippe Lecase'], [2001, 'Fresnes prison', 'France', 'No', '—'], [2002, 'Parada Neto Penitentiary', 'Brazil', 'Yes', '—'], [2002, 'Las Cucharas prison, Puerto Rico', 'United States', 'Yes', 'Orlando Cartagena Jose Rodriguez Victor Diaz Hector Diaz Jose Tapia'], [2003, 'Luynes prison', 'France', 'Yes', 'Eric AlboreoFranck PerlettoMichel Valero'], [2005, 'France', 'France', 'No', '—'], [2005, 'Aiton Prison', 'France', 'Yes', 'Hubert SellesJean-Claude MorettiMohamed Bessame'], [2006, 'Korydallos Prison', 'Greece', 'Yes', 'Vassilis Paleokostas'], [2007, 'Lantin Prison, Liège', 'Belgium', 'Yes', 'Eric Ferdinand'], [2007, 'Grasse prison', 'France', 'Yes', 'Pascal Payet'], [2007, 'Ittre prison', 'Belgium', 'No', 'Nordin Benallal'], [2009, 'Korydallos Prison', 'Greece', 'Yes', 'Vasilis PaleokostasAlket Rizai'], [2009, 'Domenjod Prison, Réunion', 'France', 'Yes', 'Alexin JismyFabrice Michel'], [2009, 'Bruges', 'Belgium', 'Yes', 'Ashraf Sekkaki plus three other criminals'], [2010, 'HM Prison Isle of Wight, Isle of Wight', 'United Kingdom', 'No', 'Brian Lawrence'], [2012, 'Sheksna, Penal colony N17', 'Russia', 'Yes', 'Alexey Shestakov'], [2013, 'Trikala Prison, Trikala', 'Greece', 'No', 'Panagiotis Vlastos'], [2013, 'Saint-Jérôme Detention Facility, Quebec', 'Canada', 'Yes', 'Benjamin Hudon-BarbeauDanny Provençal'], [2014, 'Orsainville Detention Facility, Quebec', 'Canada', 'Yes', 'Yves DenisDenis LefebvreSerge Pomerleau'], [2016, 'Thiva', 'Greece', 'No', 'Pola RoupaNikos Maziotis'], [2018, 'Réau, near Paris', 'France', 'Yes', 'Rédoine Faïd'], [2020, 'Forest prison, Brussels', 'Belgium', 'No', 'Kristel A.']]
min_year = min(data, key=lambda x: x[0])[0]
max_year = max(data, key=lambda x: x[0])[0]
To check the earliest and latest dates in the dataset
print(min_year)
print(max_year)
1971 2020
Now we'll create a list of all the years ranging from min_year to max_year
years = []
for year in range(min_year, max_year + 1):
years.append(year)
We'll see what the years look like
print(years)
[1971, 1972, 1973, 1974, 1975, 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020]
attempts_per_year = []
for year in years:
attempts_per_year.append([year, 0])
We increment the second entry by 1 each time a year appears in the data.
for row in data:
for attempt_year in attempts_per_year:
year = attempt_year[0]
if row[0] == year:
attempt_year[1] += 1
print(attempts_per_year)
[[1971, 1], [1972, 0], [1973, 1], [1974, 0], [1975, 0], [1976, 0], [1977, 0], [1978, 1], [1979, 0], [1980, 0], [1981, 2], [1982, 0], [1983, 1], [1984, 0], [1985, 2], [1986, 3], [1987, 1], [1988, 1], [1989, 2], [1990, 1], [1991, 1], [1992, 2], [1993, 1], [1994, 0], [1995, 0], [1996, 1], [1997, 1], [1998, 0], [1999, 1], [2000, 2], [2001, 3], [2002, 2], [2003, 1], [2004, 0], [2005, 2], [2006, 1], [2007, 3], [2008, 0], [2009, 3], [2010, 1], [2011, 0], [2012, 1], [2013, 2], [2014, 1], [2015, 0], [2016, 1], [2017, 0], [2018, 1], [2019, 0], [2020, 1]]
Visualizing the result in a friendlier way
%matplotlib inline
barplot(attempts_per_year)
The years in which the most attempts at breaking out of prison with a helicopter occured in 1986, 2001, 2007 and 2009, all with three attempts respectively.
countries_frequency = df["Country"].value_counts()
print_pretty_table(countries_frequency)
Country | Number of Occurrences |
---|---|
France | 15 |
United States | 8 |
Belgium | 4 |
Greece | 4 |
Canada | 4 |
Australia | 2 |
United Kingdom | 2 |
Brazil | 2 |
Mexico | 1 |
Russia | 1 |
Italy | 1 |
Puerto Rico | 1 |
Netherlands | 1 |
Chile | 1 |
Ireland | 1 |
The table shows that the country with the highest occurences of Helicopter prison escape attempts is France.
In which countries do helicopter prison breaks have a higher chance of success?
df['IsSuccess'] = df.apply(lambda row: 1 if row['Succeeded'] == 'Yes' else 0, axis=1)
#The success rate of each country
countries_success_frequency = df.groupby('Country')['IsSuccess'].mean()
#countries_success_frequency = df.groupby(["Country", "Succeeded"]).size()
countries_success_frequency.sort_values(ascending=False)
Country Russia 1.000000 Puerto Rico 1.000000 Mexico 1.000000 Italy 1.000000 Ireland 1.000000 Chile 1.000000 Brazil 1.000000 United States 0.750000 Canada 0.750000 France 0.733333 United Kingdom 0.500000 Greece 0.500000 Belgium 0.500000 Australia 0.500000 Netherlands 0.000000 Name: IsSuccess, dtype: float64
Which escapees have done it more than once?
print(df["Escapee(s)"].value_counts().sort_values(ascending=False))
— 7 Michel Vaujour 2 Pascal Payet 2 Panagiotis Vlastos 1 André BellaïcheGianluigi EspositoLuciano Cipollari 1 Ashraf Sekkaki plus three other criminals 1 John Killick 1 Ben Kramer 1 Robert FordDavid Thomas 1 Gérard DupréDaniel Beaumont 1 Eric AlboreoFranck PerlettoMichel Valero 1 William Lane 1 Sydney DraperJohn Kendall 1 Orlando Cartagena Jose Rodriguez Victor Diaz Hector Diaz Jose Tapia 1 Yves DenisDenis LefebvreSerge Pomerleau 1 Ralph BrownFreddie Gonzales 1 Brian Lawrence 1 Mahoney Danny Francis MitchellRandy Lackey 1 Steven Whitsett 1 JB O'Hagan Seamus TwomeyKevin Mallon 1 Samantha Lopez 1 Pola RoupaNikos Maziotis 1 Four members of the Manuel Rodriguez Patriotic Front 1 Joel David Kaplan Carlos Antonio Contreras Castro 1 Abdelhamid CarnousEmile Forma-SariJean-Philippe Lecase 1 Kristel A. 1 José Carlos dos Reis Encina, a.k.a. "Escadinha" 1 Rédoine Faïd 1 Hubert SellesJean-Claude MorettiMohamed Bessame 1 Alexey Shestakov 1 Alexin JismyFabrice Michel 1 Eric Ferdinand 1 Benjamin Hudon-BarbeauDanny Provençal 1 James Rodney LeonardWilliam Douglas BallewJesse Glenn Smith 1 Vasilis PaleokostasAlket Rizai 1 Garrett Brock TrapnellMartin Joseph McNallyJames Kenneth Johnson 1 David McMillan 1 Nordin Benallal 1 Vassilis Paleokostas 1 Marina Paquet (hijacker)Giles Arseneault (prisoner) 1 Name: Escapee(s), dtype: int64