#!/usr/bin/env python # coding: utf-8 # # My First Data Science Project # ## Helicopter Escapes! # We begin by importing some helper functions. # In[9]: from helper import * # In[8]: url = 'https://en.wikipedia.org/wiki/List_of_helicopter_prison_escapes' # ## 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. # In[31]: data = data_from_url(url) # Let's print the first three rows # In[47]: for values in data: print(values[:4]) # In[35]: index = 0 for row in data: data[index] = row[:-1] index += 1 print(data[:3]) # In[36]: date = "July 23, 2009" year = fetch_year(date) print(year) # In[37]: for row in data: row[0] = fetch_year(row[0]) print(data[:2]) # In[41]: min_year = min(data, key=lambda x: x[0])[0] max_year = max(data, key=lambda x: x[0])[0] # In[42]: years=[] for y in range(min_year, max_year+1): years.append(y) print(years) # In[43]: attempts_per_year=[] index = 0 for y in years: attempts_per_year.append([]) attempts_per_year[index].append(y) count=0 for row in data: if(row[0] == y): count += 1 attempts_per_year[index].append(count) index += 1 print(attempts_per_year) # In[44]: get_ipython().run_line_magic('matplotlib', 'inline') barplot(attempts_per_year) # 1986, 2001, 2007 and 2009 have more prison escapes # In[45]: countries_frequency = df["Country"].value_counts() # In[46]: print_pretty_table(countries_frequency) # In[ ]: