GP 1: Helicopter Prison Escapes

I haven’t been diligent about posting my projects as I completed them, so I’m going back and polishing them and submitting for review. Please provide any feedback on content, style, etc., as I’m about to start building my portfolio.

Helicopter Prison Escapes.ipynb (49.2 KB)

Click here to view the jupyter notebook file in a new tab

@PatrickSmith I enjoyed reading through. You carried me along for the whole process and I like it. Well done.

1 Like

@PatrickSmith great job :heart_eyes: :trophy:. You’ve done a great job. I don’t really have feedback on this one, as think you have covered all the points that I’m usually after.

If anything, I would recommend that you attempt the extra questions. I think you could also change the last table of Country vs. Number of occurrences to a bar plot. Ideal case for a data visualization.

Great job!!

1 Like

Great job!
Easy to read and understand.

  1. Before line 5.
    “It extracts the date from the end of the string.” — extracts the year from the end of the string, your whole string is the date
  2. What about the idea to group attempts by decadas, every 10 years?

@jesmaxavier, Thanks for the input. As far as converting the last table and answering the questions, I’m having trouble doing that with the skills that had been taught at that point. I’ve since worked through most of the Data Analyst path and can do it using other tools (And I knew more than that coming in), but with keeping the spirit of the project, would you suggest trying to stay within the tools we had up to that point? Just as an example, using the given barplot() function returns a graph with only the first letter of the country as the label and it’s not in the order I’d like it. I can make a much more appropriate one using matplotlib directly. Also, finding the success rate would be much easier using pandas or maybe even just a dictionary.

@PatrickSmith my opinion would be, if you know more, show more :white_check_mark:.

I know where you are coming from, I underwent the same conflict :thinking: when I started re-doing my projects.
The goal of these projects is to create a profile to show potential recruiters. So if you intend to show this, I think it is appropriate to do the best you can and update the project with more efficient methods, in this case Pandas and Matplotlib libraries.

Keep going with what you are doing! :rocket:

It could also encourage and motivate newcomers to re-visit their projects when they have learnt more.

1 Like

@jesmaxavier, thanks. I’m curious: any suggestions on how to calculate the success rate? I tried using a pivot table, but can’t find an easy way to calculate the row total. This is the best I’ve been able to come up with so far:

success_rate = escapees.pivot_table(
    index = ["Country"],
    columns = ["Succeeded"],
    values = ["Year"],
    aggfunc = 'count',
    fill_value = 0,
    margins = True,
    margins_name = "Total")["Year"]
success_rate["Percent successful"] = round((success_rate["Yes"]/success_rate["Total"]*100),2)

Also, any idea how to count the number of escapes? It appears they’re all run together so I don’t see a way to separate and count them.

Here is a solution without using pivot:

#Maps Yes as 1 and No as 0
df['Succeeded']=df['Succeeded'].apply(lambda x:1 if (x=='Yes') else 0)

#Calculates the escape rate

#Formats the escape rate for presentation'{:.1f}%'.format)

I hope the code is self-explanatory. The output you should get is as follows:

I think you can see the danger in evaluating based on the rate of successful escapees (countries like Ireland, Italy, and Mexico have had exactly one attempt and that one attempt was successful). I will leave it to your discretion on how you analyse this result.

I’m not sure of whether this is efficient coding, so if you get something better, I am happy to learn.

Thanks. I’d considered that. Was thinking of pointing that out and looking at the countries with more attempts.

Any thoughts on getting the number of escapees, other than manually counting them?

I’ve incorporated some of the suggestions. I decided not to mess with the questions involving the number of escapees since there’s no easy way to count them and the site seems inconsistent about listing them (in some places the hijacker is included in the list, in others they aren’t. Sometimes they’re listed in the details but not the list of escapees.)
Helicopter Prison Escapes.ipynb (119.4 KB)

Click here to view the jupyter notebook file in a new tab