: Visualizing The Gender Gap In College Degrees

Hello

Just completed the gender gap data visualization project, had to look at the solution notebook and other posts which i generally avoid doing early on.

Difficulty understanding converting each range for the 6 row, 3 column matrix,

What is logic using cat_index = int((sp-1)/3) to convert range (1,16,3) for column 2 in matrix

Same question : using cat_index = int((sp-2)/3) for sp in range(2,20,3): for col 3 in the matrix

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

My Code:

# column2:create loop from 1 to 16, increments of 3        
for sp in range(1,16,3):
    # for each sp increment in range divide by 3
    # to get the category index
    cat_index = int((sp-1)/3)
    # map each category item into the 6 row, 3 col plot
    ax = fig.add_subplot(6,3,sp+1)
    #subplot of 6 rows, 3 columns

# column3: loop 2,20, sp increments of 3
for sp in range(2,20,3):
    # set each sp range increment to category index
    cat_index = int((sp-2)/3)
    # map each category index into 6,3 subplot
    ax = fig.add_subplot(6,3,sp+1)

What I expected to happen:

What actually happened:

Replace this line with the output/error

Hi @neilgordonwalker,

This post may help you:

Best,
Sahil

1 Like