My First Data Science Project

Helicopter Escapes!

In [190]:
from helper import *

Get the Data

Now, let's get the data from the List of helicopter prison escapes Wikipedia article.

In [191]:
url = 'https://en.wikipedia.org/wiki/List_of_helicopter_prison_escapes#Actual_attempts'
data = data_from_url(url)

Let's print the first three rows

In [192]:
for row in data[0: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 Castro 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."]

Removing the Details

In [193]:
index = 0
for row in data:
    data[index]=row[:-1]
    index += 1
In [194]:
print(data[0:3])
[['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']]

Extracting the Year

In [195]:
for row in data:
    date = fetch_year(row[0])
    row[0] = date
print(data[0: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']]

Attempts per Year I

In [196]:
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

Attempts per Year II

In [197]:
years = []
for y in range(min_year, max_year + 1):
    years.append(y)
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]
In [198]:
attempts_per_year = []
for year in years:
    attempts_per_year.append([year,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]]

Attempts per Year III

In [199]:
for row in data:
    for y in attempts_per_year:
        if row[0] == y[0]:
            y[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]]

Used Helper (barplot)

In [200]:
%matplotlib inline
barplot(attempts_per_year)

Attempts by Country

In [201]:
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
Brazil 2
United Kingdom 2
Puerto Rico 1
Mexico 1
Chile 1
Russia 1
Netherlands 1
Ireland 1
Italy 1

For my Knowlegde and understanding

In [202]:
ef = pd.read_html("https://en.wikipedia.org/wiki/List_of_helicopter_prison_escapes")[1]
ef = ef[["Date", "Prison name", "Country", "Succeeded", "Escapee(s)"]]
countries_y = ef["Date"].value_counts()
print(countries_y)
June 25, 2010         1
2001                  1
December 1992         1
1991                  1
December 10, 1987     1
October 28, 2007      1
2003                  1
March 17, 2013        1
May 28, 2001          1
February 27, 1981     1
June 7, 2014          1
April 27, 2009        1
January, 1983         1
July 2005             1
July 11, 1988         1
September 25, 2020    1
February 22, 2016     1
July 1, 2018          1
February 22, 2009     1
April 17, 1989        1
June 6, 2006          1
August 19, 1989       1
May 24, 1978          1
December 30, 2002     1
June 17, 1993         1
February 24, 2013     1
March 24, 2001        1
November 23, 1986     1
December 30, 1996     1
May 26, 1986          1
July 15, 2007         1
June 19, 1990         1
June 5, 2000          1
April 15, 2007        1
March 22, 2012        1
January 17, 2002      1
2000                  1
December 19, 1985     1
1992                  1
December 10, 2005     1
December 31, 1985     1
August 19, 1971       1
March 25, 1999        1
July 23, 2009         1
May 7, 1981           1
September 18, 1997    1
November 5, 1986      1
October 31, 1973      1
Name: Date, dtype: int64
In [ ]:
 
In [ ]:
 
In [ ]: