Challenge 13 Megathread

For any and all questions relating to Challenge 13 :point_down: post away!

This challenge was the best one yet, a big thanks to the peeps at JAMH.ai
The tutorial was straightforward and included all the needed functions.

FYI: The histogram won’t line up perfectly with the answer to question 1. For me, the upper range seemed to be off by about 2.5.
Instead, use the second question to choose the right response.

2 Likes

So I got both the plots the same as in the solution but I totally didn’t understand what I was suppose to read from those plots. I thought I had it but I got both attempts wrong. The correct answer doesn’t seem to me like it should be the correct answer.

@tomek The box plot gives an unambiguous answer. It asks for max temp so check out the highest dot on the box plot.

The box plot is for rainfall, right? And the highest dot is on 80mm. I don’t understand how to read the temperature from it.

@tomek use hist for temp but it will give ambiguous answers because the histogram bars are all merged together. But there’s only one m/c that matches the right box plot answer anyways so no need to figure out the hist.
Edit: using .hist() will make the grid show on the histogram to make it more readable

3 Likes

Now I see what you mean. Damn it! Oh well, there’s another day tomorrow to score some points.

Yeah mine didn’t line up perfectly.

Here’s something I found that was useful in that regard:

How To Set An Outline to Histogram Bars
Pass the following keyword arguments into the plot method:
edgecolor="black", linewidth=1.2

Like so

.plot(kind="hist", edgecolor="black", linedwith=1.2)

Edit1: Another method is to use .hist() like userUwU suggested.
Edit2: @userUwU I played around with this a bit and I realized that your approach of using .hist() and my approach of using .plot(kind="hist", edgecolor="black", linewidth=1.2) do two different things.

  1. Yours makes grid lines.
  2. Mine gives an outline to the bars.

I also realized that we can combine the two to get the best of both worlds! Like so:

.hist(edgecolor="black", linewidth=1.2)

The resulting graph … it’s beautiful :smiling_face_with_tear:

8 Likes

Does anyone feel that the graphs are taking too much time to build? Mine hasnt buit since last 20 minutes.

Even the tutorial.

Buddy, this helped. The graph was perfect

1 Like

Hi all, I will be moderating the forum for the next 2 hours. Please let me know if you face any barriers in attempting to complete todays challenge. Also, please remember to not share any answers on this forum.

Denver

Yep, I never got a single graph built. I have no idea what I did wrong because it clearly was looking at the right data as my return said my y-axis was frequency but no graph appeared. I got the correct answer on today’s challenge because I got the second part correct and it was the only one in the choices to have that approximate value.

1 Like

After messing up yesterday’s challenge and feeling a tiiiiny bit defeated, today was really fun! I’m learning so much! Thanks for all the wonderful tips in these threads :smile:

The notebook was acting up for me too on this site. Sometimes it would work if I ran the cell twice, but not always. It froze at one point so I downloaded the csv file and completed the challenge on google colab instead.

1 Like

How do you download the .csv?

I’ve been curious about doing so because these cells have been buggy sometimes, and I’d like to be able to do the challenge in VSC.

1 Like

Two ways!

  1. Option 1: You can go to my github and download it:
    GitHub - YWondimu/CSV-Files-For-LHL-21-Day-Python-Challenge: CSV Files for LHL 21 Day Python Challenge. This repository is a temporary repo to allow others to download csv files that are temporarily unavailable on LHL's site.
    To download, click on Code and choose Download ZIP.

  2. Option 2: You can use the below code in a cell of the challenge to download the file. Make sure to replace "EDIT_THIS_FILENAME.csv" with the actual file name. For example: "wine.csv". Then click on the download button that appears after you run this code.

import base64
import pandas as pd
from IPython.display import HTML

# Replace EDIT_THIS_FILENAME with the name of the csv file
filename = "EDIT_THIS_FILENAME.csv"

def create_download_link( df, title = "Download CSV file", filename = filename):
    csv = df.to_csv()
    b64 = base64.b64encode(csv.encode())
    payload = b64.decode()
    html = '<a download="{filename}" href="data:text/csv;base64,{payload}" target="_blank">{title}</a>'
    html = html.format(payload=payload,title=title,filename=filename)
    return HTML(html)

download = pd.read_csv(filename)
create_download_link(download)

#Click on the download button that appears

Check out this post for more on the second method:

Edit: Today’s CSV Is A Big File
Just a bit of warning – Today’s csv took me a while to download (took like 5 tries) and a while to upload (maybe 5 minutes?). I think it’s much larger than previous csv’s.