Can someone answer this questions in 3rd chapter of Guided Project

Use the plots to explore the following questions:

  • What percent of majors are predominantly male? Predominantly female?
  • What’s the most common median salary range?
2 Likes

I have the same issue with the first one, for now. But for the second question I’d say 20000 - 50000.

1 Like

thank you , hope someone give us a clear answer for both questions.

1 Like

Hi @somar1990,

These two posts explains it very well.

image

The most common is the salary range with the highest frequency. So for the above case, it is 30k - 40k.

To be specific, the graph represents 30800.0 - 39600.0 as the most common range:

pd.cut(recent_grads['Median'], bins=10).value_counts()

(30800.0, 39600.0]      75
(39600.0, 48400.0]      40
(21912.0, 30800.0]      24
(48400.0, 57200.0]      18
(57200.0, 66000.0]      11
(66000.0, 74800.0]       2
(101200.0, 110000.0]     1
(74800.0, 83600.0]       1
(92400.0, 101200.0]      0
(83600.0, 92400.0]       0
Name: Median, dtype: int64

Best,
Sahil

1 Like

Hello,

This is just a similar approach, in case you would like to get the exact numbers using the histogram. First, you may want to create a histogram with just two bins. One bin with the “ShareWomen” < 0.5, and another one with the “ShareWomen” > 0.5. You may also want to adjust your ticks and ylim to see the exact numbers.

fig, ax = plt.subplots(figsize=(2,6))
ax.hist(recent_grads["ShareWomen"], bins=2)
ax.set_yticks(np.arange(70,100,step=2))
ax.set_ylim(70,100)
plt.show()

Output:
image

Thus, you will have 74 majors (43%) with a share of women of less than 50%, and 98 majors (57%) with a share of women more than 50%.

Roman.

1 Like

You can also extract the most common “Median” number by using histograms and setting the number of bins to the number of rows :

fig, ax = plt.subplots(figsize=(10,6))
ax.hist(recent_grads["Median"], bins=172)
ax.set_xticks(np.arange(20000,60000,step=5000))
ax.set_xlim(20000,60000)
plt.show()

image

The most common “Median” would be 35000 (20 majors). If you want a broader range just experiment with a number of bins.

Regards,

Roman

2 Likes