#!/usr/bin/env python # coding: utf-8 # # My First Data Science Project # ## Helicopter Escapes! # We begin by importing some helper functions. # In[99]: 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. # Let's print the first three rows # In[102]: url = "https://en.wikipedia.org/wiki/List_of_helicopter_prison_escapes" data = data_from_url(url) # In[103]: data[:3] # # Removing the last element of each row (the Details) # In[104]: index = 0 for row in data: data[index] = row[:-1] index += 1 data[:3] # # Replacing of element # In[105]: for row in data: row[0] = fetch_year(row[0]) data[:3] # # Creating a list # In[111]: min_year = min(data, key=lambda x: x[0])[0] max_year = max(data, key=lambda x: x[0])[0] min_year # In[110]: max_year # In[112]: years = [] for y in range(min_year, max_year + 1): years.append(y) years # # Breakdown of attempts per year # In[113]: attempts_per_year = [] for y in years: attempts_per_year.append([y, 0]) # In[128]: for row in data: for ya in attempts_per_year: y=ya[0] if row[0] == y: ya[1] += 1 print(attempts_per_year) # # Visualization of the Breakdown of attempts per year # In[129]: get_ipython().run_line_magic('matplotlib', 'inline') barplot(attempts_per_year) # According to the plot, most attempts at breaking out of # prison occured in the years 1986, 2001, 2007 and 2009 with # a total count of 3. # In[130]: countries_frequency = df["Country"].value_counts()