#!/usr/bin/env python # coding: utf-8 # # My First Data Science Project # ## Helicopter Escapes # ### We begin by importing some helper functions. # In[8]: 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. # In[9]: url = 'https://en.wikipedia.org/wiki/List_of_helicopter_prison_escapes' data = data_from_url(url) # ### Let's print the first three rows # In[10]: for row in data: print(data[:3]) # In[11]: index = 0 for row in data: data[index] = row index = index + 1 print(data) # In[12]: for row in data: row[0] = fetch_year(row[0]) print(data) # In[40]: min_year = min(data, key=lambda x: x[0])[0] max_year = max(data, key=lambda x: x[0])[0] years = [] for y in range(min_year, max_year + 1): years.append(y) attempts_per_year = [] for y in years: attempts_per_year.append([y, 0]) print(attempts_per_year) # In[41]: # Instruction 1 - for each row in data for row in data: for ya in attempts_per_year: # Instruction 2 - nothing to do here # Instruction 3 - assign the year value in ya to y y = ya[0] if row[0] == y: ya[1] += 1 print(attempts_per_year) # Instruction 4 - print the results # In[42]: get_ipython().run_line_magic('matplotlib', 'inline') barplot(attempts_per_year) # ### In which year did the most attempts at breaking out of prison with a helicopter occur? # In[ ]: 2020 # In[44]: countries_frequency = df["Country"].value_counts() # In[ ]: print