The data used in the analysis of prison escapes by means of helicopter is from a Wikipedia article titled 'List of Helicopter Prison Escapes' and can be found here:
https://en.wikipedia.org/wiki/List_of_helicopter_prison_escapes
The intent of the analysis is to:
opened_file = open('C:\Shaun\Businesses\Mr Data\Datasets\Helicopter Prison Escapes.csv')
from csv import reader
read_file = reader(opened_file)
dataset = list(read_file)
data = dataset[1:]
All elements of the first row of the dataset were printed to verify that the correct Wikipedia data was pulled from the 'url' cited in the previous cell.
print(data[:1])
[['1971-08-19', 'Santa Martha Acatitla', 'Â\xa0Mexico', 'Yes', 'Joel David Kaplan, Carlos Antonio, Contreras Castro', "Joel David Kaplan was aÂ\xa0New YorkÂ\xa0businessman who had been arrested for murder in 1962 inÂ\xa0Mexico CityÂ\xa0and was incarcerated at the Santa Martha Acatitla prison in theÂ\xa0IztapalapaÂ\xa0borough 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Â\xa0VenezuelanÂ\xa0counterfeiter, were able to board the craft and were piloted away, before any shots were fired.[9]Â\xa0Both men were flown toÂ\xa0TexasÂ\xa0and then different planes flew Kaplan toÂ\xa0CaliforniaÂ\xa0and Castro toÂ\xa0Guatemala.[3]Â\xa0The Mexican government never initiated extradition proceedings against Kaplan.[9]Â\xa0The escape is told in a book,Â\xa0The 10-Second Jailbreak: The Helicopter Escape of Joel David Kaplan.[4]Â\xa0It also inspired the 1975Â\xa0action movieÂ\xa0Breakout, which starredÂ\xa0Charles BronsonÂ\xa0andÂ\xa0Robert Duvall.[9]"]]
The dataset was modified to remove the last element of each row which is the long-text information in the 'Details' column; this action was performed to "clean-up" the data. The first three rows of the dataset are printed to demonstrate this action.
index = 0
for row in data:
data[index] = row[:-1]
index += 1
print(data[:5])
[['1971-08-19', 'Santa Martha Acatitla', 'Â\xa0Mexico', 'Yes', 'Joel David Kaplan, Carlos Antonio, Contreras Castro'], ['1973-10-31', 'Mountjoy Jail', 'Â\xa0Ireland', 'Yes', "JB O'Hagan, Seamus Twomey, Kevin Mallon"], ['1978-05-24', 'United States Penitentiary, Marion', 'Â\xa0United States', 'No', 'Garrett Brock Trapnell, Martin Joseph McNally, Martin Joseph McNally, James Kenneth Johnson'], ['1981-02-27', 'Fleury-Mérogis, Essonne, Ile de France', 'Â\xa0France', 'Yes', 'Gérard Dupré, Daniel Beaumont'], ['1981-05-07', 'Orsainville Prison, Quebec City', 'Â\xa0Canada', 'No', 'Marina Paquet (hijacker), Giles Arseneault (prisoner)']]
The analysis is only concerned with the year and the number of helicopter prison escape attempts that took place for each year. The dataset's first element for each row, the 'Date' column, was extracted and modified from the 'Month, Day, Year" format to only include the year (yyyy) each escape attempt took place and stored in a new list called 'Year'; the 'Year' list was printed to confirm the extraction.
Year = []
for row in data:
Date = row[0]
yyyy = (int(Date[:4]))
Year.append(yyyy)
print(Year)
[1971, 1973, 1978, 1981, 1981, 1983, 1985, 1985, 1986, 1986, 1986, 1987, 1988, 1989, 1989, 1990, 1991, 1992, 1992, 1993, 1996, 1997, 1999, 2000, 2000, 2001, 2001, 2001, 2002, 2002, 2003, 2005, 2005, 2006, 2007, 2007, 2007, 2009, 2009, 2009, 2010, 2012, 2013, 2013, 2014, 2016, 2018, 2020]
The following three cells create a new list to demonstrate which year(s) had the most helicopter prison break attempts in the format [yyyy, n], where 'n' equals the total number of attempts per year. The final list will include years that had no prison escape attempts as well.
# Range of all years from the first registered attempt until the last.
min_year = min(Year)
max_year = max(Year)
print('Range of all years from the first registered helicopter prison escape attempt until the last:')
print('')
print(min_year, 'to', max_year, '-', len(Year), 'attempts total over', max_year - min_year, 'years.')
Range of all years from the first registered helicopter prison escape attempt until the last: 1971 to 2020 - 48 attempts total over 49 years.
# List of all consecutive years from min_year to max_year.
all_years = []
for year in range(min_year, max_year + 1):
all_years.append(year)
print('List of all consecutive years within the range of years determined in cell [5] above:')
print(' ')
print(all_years)
List of all consecutive years within the range of years determined in cell [5] above: [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 yyyy in all_years:
attempts_per_year.append([yyyy, 0])
print(attempts_per_year)
# Remember, Year[] is a list recording the year each escape attempt that took place.
for index in Year:
for row in attempts_per_year:
yyyy = row[0]
if index == yyyy:
row[1] += 1
print(' ')
print('List of helicopter prison escape attempts per year from 1971 to 2020:')
print(' ')
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]] List of helicopter prison escape attempts per year from 1971 to 2020: [[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]]
from matplotlib import pyplot as plt
year = []
for row in attempts_per_year:
yr = row[0]
year.append(yr)
# print(year)
attempts = []
for row in attempts_per_year:
count = row[1]
attempts.append(count)
# print(attempts)
Color = 'grey'
bar_colors = ['red', 'blue', 'orange', 'green']
plt.figure(figsize = (16, 5))
ax = plt.axes()
ax.set_facecolor('0.85') # Background Color
plt.bar(year, attempts, color = bar_colors, edgecolor = 'black', width = .85, hatch = ('//'))
plt.title('Helicopter Prison Escape Attempts per Year', fontsize = 18)
plt.ylabel('Attempts per Year', fontsize = 16)
plt.xlabel('Year', fontsize = 16,)
plt.grid(color = Color, alpha = 0.3, linestyle = '--', linewidth = 1)
plt.xticks(year, horizontalalignment = 'center', rotation = 'vertical')
plt.yticks(attempts)
plt.show()
The most helicopter prison escape attempts took place in the years 1986, 2001, 2007, and 2009 with three attempts in each year respectively.
Chart 2 organizes the data to demonstrate how many helicopter prison escape attempts have occured in each country where an attempt was registered from 1971 to 2020.
# 'Country' is a list recording the country each escape attempt that took place.
Country = []
for row in data:
country = row[2]
Country.append(country)
print(Country)
print(' ')
# remove duplicates from Country[].
all_Countries = list(set(Country))
print(all_Countries)
print(' ')
attempts_per_country = []
for country in all_Countries:
attempts_per_country.append([0, country])
print(attempts_per_country)
print(' ')
for index in Country:
for row in attempts_per_country:
country = row[1]
if index == country:
row[0] += 1
# attempts_per_country[] is sorted from the country or countries with the most attempts to the least.
attempts_per_country.sort(reverse = True)
print(attempts_per_country)
['Â\xa0Mexico', 'Â\xa0Ireland', 'Â\xa0United States', 'Â\xa0France', 'Â\xa0Canada', 'Â\xa0Australia', 'Â\xa0United States', 'Â\xa0Brazil', 'Â\xa0France', 'Â\xa0United States', 'Â\xa0Italy', 'Â\xa0United Kingdom', 'Â\xa0United States', 'Â\xa0United States', 'Â\xa0United States', 'Â\xa0Canada', 'Â\xa0Puerto Rico', 'Â\xa0France', 'Â\xa0France', 'Â\xa0France', 'Â\xa0Chile', 'Â\xa0Netherlands', 'Â\xa0Australia', 'Â\xa0United States', 'Â\xa0France', 'Â\xa0France', 'Â\xa0France', 'Â\xa0France', 'Â\xa0Brazil', 'Â\xa0United States', 'Â\xa0France', 'Â\xa0France', 'Â\xa0France', 'Â\xa0Greece', 'Â\xa0Belgium', 'Â\xa0France', 'Â\xa0Belgium', 'Â\xa0Greece', 'Â\xa0France', 'Â\xa0Belgium', 'Â\xa0United Kingdom', 'Â\xa0Russia', 'Â\xa0Greece', 'Â\xa0Canada', 'Â\xa0Canada', 'Â\xa0Greece', 'Â\xa0France', 'Â\xa0Belgium'] ['Â\xa0France', 'Â\xa0United Kingdom', 'Â\xa0Greece', 'Â\xa0Chile', 'Â\xa0Brazil', 'Â\xa0Russia', 'Â\xa0Belgium', 'Â\xa0Netherlands', 'Â\xa0Australia', 'Â\xa0Italy', 'Â\xa0Ireland', 'Â\xa0Canada', 'Â\xa0Mexico', 'Â\xa0United States', 'Â\xa0Puerto Rico'] [[0, 'Â\xa0France'], [0, 'Â\xa0United Kingdom'], [0, 'Â\xa0Greece'], [0, 'Â\xa0Chile'], [0, 'Â\xa0Brazil'], [0, 'Â\xa0Russia'], [0, 'Â\xa0Belgium'], [0, 'Â\xa0Netherlands'], [0, 'Â\xa0Australia'], [0, 'Â\xa0Italy'], [0, 'Â\xa0Ireland'], [0, 'Â\xa0Canada'], [0, 'Â\xa0Mexico'], [0, 'Â\xa0United States'], [0, 'Â\xa0Puerto Rico']] [[15, 'Â\xa0France'], [8, 'Â\xa0United States'], [4, 'Â\xa0Greece'], [4, 'Â\xa0Canada'], [4, 'Â\xa0Belgium'], [2, 'Â\xa0United Kingdom'], [2, 'Â\xa0Brazil'], [2, 'Â\xa0Australia'], [1, 'Â\xa0Russia'], [1, 'Â\xa0Puerto Rico'], [1, 'Â\xa0Netherlands'], [1, 'Â\xa0Mexico'], [1, 'Â\xa0Italy'], [1, 'Â\xa0Ireland'], [1, 'Â\xa0Chile']]
country = []
for row in attempts_per_country:
cy = row[0]
country.append(cy)
# print(country)
attempt_total = []
for row in attempts_per_country:
total = row[1]
attempt_total.append(total)
# print(attempt_total)
Color = 'white'
New_Colors = ['turquoise']
plt.figure(figsize = (14, 5))
ax = plt.axes()
ax.set_facecolor('0.85') # Background Color
plt.grid(color = Color, alpha = 0.3, linestyle = '--', linewidth = 1)
plt.bar(attempt_total, country, color = New_Colors, edgecolor = 'white', width = .85)
plt.title('Helicopter Prison Escape Attempts per Country', fontsize = 18)
plt.ylabel('Escape Attempt Total Count', fontsize = 16)
plt.xlabel('Country', fontsize = 16,)
plt.xticks(attempt_total, horizontalalignment = 'right', rotation = '45')
plt.yticks(country)
plt.show()
The most helicopter prison escape attempts from 1971 to 2020 have occured in France with 15 attempts total.
Further analysis was completed to determine the helicopter prison escape success rate depending on which country the escape was attempted in. A quick summary shows that over 49 years from 1971 to 2020, there were a total of 48 helicopter prison escape attempts recorded in 15 different countries. France leads the way with 15 total escape attempts; but, in which country or countries would you have the best chance for success? Chart 3 displays the results followed by some interpretation.
country_yes_no = []
for row in data:
country = row[2]
country_yes_no.append([row[2], row[3]])
# print(country_yes_no)
# print(' ')
country_success_count = []
for country in all_Countries:
country_success_count.append([country, 0])
# print(country_success_count)
# print(' ')
for yes_no in country_yes_no:
for row in country_success_count:
country = row[0]
if yes_no[0] == country and yes_no[1] == 'Yes':
row[1] += 1
# country_success_count[] sorted alphabetically.
country_success_count.sort()
print(country_success_count)
print(' ')
# attempts_per_country_[] sorted specifically by index [1] of each row.
attempts_per_country_sorted = attempts_per_country
attempts_per_country_sorted.sort(key=lambda x: x[1])
print(attempts_per_country_sorted)
[['Â\xa0Australia', 1], ['Â\xa0Belgium', 2], ['Â\xa0Brazil', 2], ['Â\xa0Canada', 3], ['Â\xa0Chile', 1], ['Â\xa0France', 11], ['Â\xa0Greece', 2], ['Â\xa0Ireland', 1], ['Â\xa0Italy', 1], ['Â\xa0Mexico', 1], ['Â\xa0Netherlands', 0], ['Â\xa0Puerto Rico', 1], ['Â\xa0Russia', 1], ['Â\xa0United Kingdom', 1], ['Â\xa0United States', 6]] [[2, 'Â\xa0Australia'], [4, 'Â\xa0Belgium'], [2, 'Â\xa0Brazil'], [4, 'Â\xa0Canada'], [1, 'Â\xa0Chile'], [15, 'Â\xa0France'], [4, 'Â\xa0Greece'], [1, 'Â\xa0Ireland'], [1, 'Â\xa0Italy'], [1, 'Â\xa0Mexico'], [1, 'Â\xa0Netherlands'], [1, 'Â\xa0Puerto Rico'], [1, 'Â\xa0Russia'], [2, 'Â\xa0United Kingdom'], [8, 'Â\xa0United States']]
# a list of only the attempts per country count.
attempts = []
for row in attempts_per_country_sorted:
a = row[0]
attempts.append(a)
print(attempts)
print(' ')
# a list of only the successful attempts per country count.
successes = []
for row in country_success_count:
s = row[1]
successes.append(s)
print(successes)
print(' ')
# to arrange country_success_count[] alphabetically
country_alpha = []
for row in country_success_count:
country = row[0]
country_alpha.append(country)
print(country_alpha)
print(' ')
# combine successes[0][0] to attempts[0][0]...
successes_vs_attempts = [[x] + [y] for x, y in zip(successes, attempts)]
print(successes_vs_attempts)
print(' ')
success_rate = []
for row in successes_vs_attempts:
success = row[0]
attempt = row[1]
rate = (success / attempt) * 100
success_rate.append(rate)
#print(success_rate)
# print(success_rate)
# print(' ')
# convert float[] to int[]
success_rate_int = [int(index) for index in success_rate]
print(success_rate_int)
print(' ')
# to combine each success rate to it's respective country to create a final list called success_rate_per_country.
success_rate_per_country = [[x] + [y] for x, y in zip(success_rate_int, country_alpha)]
print(success_rate_per_country)
[2, 4, 2, 4, 1, 15, 4, 1, 1, 1, 1, 1, 1, 2, 8] [1, 2, 2, 3, 1, 11, 2, 1, 1, 1, 0, 1, 1, 1, 6] ['Â\xa0Australia', 'Â\xa0Belgium', 'Â\xa0Brazil', 'Â\xa0Canada', 'Â\xa0Chile', 'Â\xa0France', 'Â\xa0Greece', 'Â\xa0Ireland', 'Â\xa0Italy', 'Â\xa0Mexico', 'Â\xa0Netherlands', 'Â\xa0Puerto Rico', 'Â\xa0Russia', 'Â\xa0United Kingdom', 'Â\xa0United States'] [[1, 2], [2, 4], [2, 2], [3, 4], [1, 1], [11, 15], [2, 4], [1, 1], [1, 1], [1, 1], [0, 1], [1, 1], [1, 1], [1, 2], [6, 8]] [50, 50, 100, 75, 100, 73, 50, 100, 100, 100, 0, 100, 100, 50, 75] [[50, 'Â\xa0Australia'], [50, 'Â\xa0Belgium'], [100, 'Â\xa0Brazil'], [75, 'Â\xa0Canada'], [100, 'Â\xa0Chile'], [73, 'Â\xa0France'], [50, 'Â\xa0Greece'], [100, 'Â\xa0Ireland'], [100, 'Â\xa0Italy'], [100, 'Â\xa0Mexico'], [0, 'Â\xa0Netherlands'], [100, 'Â\xa0Puerto Rico'], [100, 'Â\xa0Russia'], [50, 'Â\xa0United Kingdom'], [75, 'Â\xa0United States']]
Color = 'grey'
bar_colors = ['tomato', 'tomato', 'green', 'orange', 'green', 'orange', 'tomato', 'green', 'green', 'green', 'black', 'green', 'green', 'tomato', 'orange']
plt.figure(figsize = (15, 4))
ax = plt.axes()
ax.set_facecolor('0.85') # Background Color
plt.bar(country_alpha, success_rate_int, color = bar_colors, edgecolor = 'black', width = .75, hatch = '')
plt.title('Helicopter Prison Escape Attempt Success Rate per Country', fontsize = 18)
plt.ylabel('Success Rate (%)', fontsize = 16)
plt.xlabel('Country', fontsize = 16,)
plt.grid(color = Color, alpha = 0.1, linestyle = '--', linewidth = 1)
plt.xticks(country_alpha, horizontalalignment = 'right', rotation = '45')
plt.yticks([0, 25, 50, 75, 100])
plt.show()
According to Chart 3, countries with a 100% helicopter prison escape success rate include: Brazil, Chile, Ireland, Italy, Mexico, Netherlands, Puerto Rico, and Russia. All the countries listed with a 100% success rate only had one recorded escape attempt with the exception being Brazil with two successful escapes from two attempts. The country with the best chances for escaping prison via a helicopter is Brazil. This conclusion is based *only* on the country with the highest escape attempt success rate and then the highest number of recorded escape attempts.
If countries were isolated by a higher sample size of four or more helicopter prison escape attempts, the list of countries with the highest success rate would include: Belgium (50% success), Canada (75%), France (73%), Greece (50%), and the United States (75%). Using the same criteria to select Brazil in the previous section, Canada and the United States are the countries with the best chance for escaping prison with a helicopter in this case.