Gender gap in college degrees - nested loop

Hi all,

Here’s my take on this project, feedback is welcome. I tried to avoid hardcoding values as much as possible.

A better way would be using enumerate() as suggested here. The counting of loop variables is then automatic.

https://app.dataquest.io/m/149/guided-project%3A-visualizing-the-gender-gap-in-college-degrees/6/exporting-to-a-file

Basics.ipynb (211.4 KB)

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

1 Like

Hi @alexminos,

That’s a nice submission you’ve made. Good job avoiding hardcoding values as much as possible. However, I have a few suggestions:

  1. Include a project title. This is to help readers know what this project is about.
  2. Document what you are doing so it’s easy for others to follow. Your documentation doesn’t have to be lengthy. Small blocks of text describing the results of code cells or decisions you make or even thoughts you have about the way the project should go will help readers understand your project better.
  3. It’s helpful to document what you find interesting about your plots. About 3 - 5 insights is a good amount.
  4. It’s helpful to include a conclusion at the end of the project. It should be a summary of the takeaways from the project. Something the reader can go through and get the full gist of the entire project.

I holp this helps!

2 Likes

Hi @alexminos,

I think whatever @adewalade mentioned above are important points which you have to include in your project. So I’m not repeating it.

Though I have found a few things you can consider if you are updating this projeect.

You have used the below code in cell no. 10 but not in cell no. 8.

key,spine in ax.spines.items():
        spine.set_visible(False)

So if you want to one more method, here is another, by using just one iterating variable.

key in ax.spines.values():

I think this way the code is easier to understand than with 2 iteration variables. Both works fine though.

It is quite nice to understand how you have printed the three plots with one set of code block. It is a good learning for me.

It would be great if you can explain the execution flow of this line of code

max_row = max([len(cats[:][i]) for i in range(n_cols)])

Will it first execute the for loop and come back to len()?
I’m just wondering how cats[:][i] gets the value for i

2 Likes

Hi and thanks for the feedback.
About your max_row question, it does look weird but it’s standard python syntax. It’s called list comprehension and you can read the whole story here

2 Likes

Thanks a lot for sharing this. I’ve read about list comprehension and it is a nice trick to create a list or an output from a list.

1 Like