<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by André on Medium]]></title>
        <description><![CDATA[Stories by André on Medium]]></description>
        <link>https://medium.com/@iamandre?source=rss-37253f54f98f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*MUTlkSinD59xBF9-8ilenQ.jpeg</url>
            <title>Stories by André on Medium</title>
            <link>https://medium.com/@iamandre?source=rss-37253f54f98f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 07:02:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@iamandre/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Prison Break: Analysing Helicopter Prison Escape Data]]></title>
            <link>https://medium.com/@iamandre/prison-break-analysing-helicopter-prison-escape-data-87c111d33bf6?source=rss-37253f54f98f------2</link>
            <guid isPermaLink="false">https://medium.com/p/87c111d33bf6</guid>
            <category><![CDATA[dataquest]]></category>
            <category><![CDATA[pandas]]></category>
            <category><![CDATA[beautifulsoup]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[data-analysis]]></category>
            <dc:creator><![CDATA[André]]></dc:creator>
            <pubDate>Sat, 16 Apr 2022 16:57:26 GMT</pubDate>
            <atom:updated>2022-04-16T17:14:46.089Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-4J9z1rKiRrNw_XKCJ2RFA.jpeg" /></figure><p>Ever finished Season 1 of Golden Globe nominated serial drama <a href="https://www.imdb.com/title/tt0455275/">Prison Break</a> and wondered if cinematic prison escapes occur in the real world? The short answer — Yes they do!</p><p>In this article we’re going to analyse a small dataset of prison escapes where a helicopter was used in an attempt to free prisoners from a place of internment, a prison, or correctional facility. (<a href="https://en.wikipedia.org/wiki/List_of_helicopter_prison_escapes">https://en.wikipedia.org/wiki/List_of_helicopter_prison_escapes</a>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HceWol_P58DAGPEkmNiQzw.jpeg" /><figcaption>Figure 1 — Wikipedia table.</figcaption></figure><p>The aim of this this project is to answer the following questions:</p><ol><li>In which year did the most helicopter prison break attempts occur?</li><li>In which countries do the most attempted helicopter prison escapes occur?</li></ol><h3><strong>Required Libraries</strong></h3><p>To undertake this analysis, the following libraries were installed:</p><pre><strong>import </strong>pandas<strong> as </strong>pd<br><strong>import</strong> requests<br><strong>from</strong> bs4 <strong>import</strong> BeautifulSoup</pre><h3>Web Scraping with Beautiful Soup</h3><p>Web scraping function <strong><em>data_from_url()</em></strong> was defined to extract the data. In summary, the function <strong><em>requests</em></strong> data from a <strong><em>url</em></strong> by firstly checking that the status of the webpage is ok (<strong><em>HTTP 200 code</em></strong>) and upon confirmation extracts the data under a defined <strong><em>tag_name</em></strong> and <strong><em>class_name</em></strong>.</p><pre><strong>def</strong> data_from_url(https://medium.com/url,tag_name,class_name):</pre><pre>    response = requests.get(url)</pre><pre>    <strong>if</strong> response.status_code != 200:</pre><pre>        print(&#39;HTTP 404: Page not found&#39;)</pre><pre>    <strong>else</strong>:</pre><pre>        soup = BeautifulSoup(response.text,&#39;html.parser&#39;)</pre><pre>        html_output = soup.find(tag_name,{&#39;class&#39;:class_name})</pre><pre>        output = pd.read_html(str(html_output))</pre><pre>    <strong>return</strong> output[0]</pre><p>Running the function produces.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i2k87xIdST23oC6X183TZw.jpeg" /><figcaption>Figure 2 — Raw data from wikipedia.</figcaption></figure><h3>Data Cleaning</h3><p>In order to calculate which year the most helicopter escapes occurred, the years from the date column need to be extracted and counted. A way of doing this is to convert the <strong><em>Date</em></strong> column to a datetime object then reducing the entries to their year. This can be done using pandas datetime functionality.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-b6XeomSFJXCVC-yJemeLg.jpeg" /><figcaption>Figure 3— Raw data information.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DgeGXTOKEFhad-R1pbr9Xg.jpeg" /><figcaption>Figure 4— Cleaned Dataset.</figcaption></figure><p>At this stage is not apparent that the dataset requires cleaning to determine which countries have had the most helicopter escapes.</p><h3>Graphs</h3><p>We’re going to answer both questions by producing bar plots.</p><p><strong>Prison Breaks per Year</strong></p><pre>escape_year_plot = escape_data[&#39;Date&#39;].dt.year.value_counts().plot(kind=&#39;bar&#39;,xlabel = &#39;Year&#39;,ylabel = &#39;No. of Escapes&#39;,title = &#39;Prison Breaks Per Year&#39;,figsize = (12,6))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*TSNlxYVmoWuaVDATp-b1Nw.png" /></figure><p><strong>Prison Breaks per Country</strong></p><pre>escape_country_plot = escape_data[&#39;Country&#39;].value_counts().plot(kind=&#39;bar&#39;,xlabel = &#39;Country&#39;,ylabel = &#39;No. of Escapes&#39;,title = &#39;Prison Breaks per Country&#39;,figsize = (12,6))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/717/1*5znuM31s8kjdM76yrRr-Hg.png" /></figure><h3>Conclusion</h3><p>It can be concluded that there has been a maximum of three recorded prison escapes by helicopter in one year. This has happened during years 1986, 2001, 2007 &amp; 2009.</p><p>France has the 14 recorded prison escapes by helicopter, more than any other country on record.</p><p>This project was completed as part of Dataquests Data Science Course (<a href="https://www.dataquest.io/">Dataquest.io</a>).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=87c111d33bf6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>