#!/usr/bin/env python # coding: utf-8 # # My First Data Science Project # ## Helicopter Escapes! # We begin by importting some helper functions # In[3]: from helper import* # ## Get the Data # In[4]: url = "https://en.wikipedia.org/wiki/List_of_helicopter_prison_escapes" # 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 # In[5]: data = data_from_url(url) # In[6]: print(data) # let's print the first three rows # In[7]: for row in data[:3]: print(row) # # Removing the last row. "Details" # In[8]: index = 0 for row in data: data[index] = row[:-1] index +=1 # In[9]: print(data[:3]) # Asjusting first row. Removing days and months # In[10]: for row in data: date = fetch_year(row[0]) row[0] = date # In[11]: print(data[:3]) # In[12]: min_year = min(data, key=lambda x: x[0])[0] max_year = max(data, key=lambda x: x[0])[0] # In[17]: years = [] for y in range(min_year, max_year + 1): years.append(y) # In[18]: print(years) # In[38]: attempts_per_year = [] for y in years: attempts_per_year.append([y, 0]) # In[39]: print(attempts_per_year) # In[40]: for row in data: for ya in attempts_per_year: y = ya[0] if row[0] == y: ya[1] += 1 print(attempts_per_year) # in which year did the most attempts at breaking out of prison with a helicopter occur? # In[41]: get_ipython().run_line_magic('matplotlib', 'inline') barplot(attempts_per_year) # The most attempts for helicopter escapes happened in 2009, 2007, 2001, and 1986 with 3 attempts each # In[44]: countries_frequency = df["Country"].value_counts() print(countries_frequency) # In[ ]: