Proportion of Females
We aim to analyze the gender distribution across all categories of the awards, including Economic Sciences, Physics, Chemistry, Peace, Physiology or Medicine, and Literature, to identify which gender predominates in each field.
Taak
Swipe to start coding
-
Create a new column in the
nobel
DataFrame that identifies if a laureate isfemale
. -
Calculate the decade for each Nobel Prize award.
-
Compute the proportion of female winners for each decade and category.
-
Plot the proportion of female winners per decade by categories.
Oplossing
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# Create a new column to identify if the laureate is female
nobel["female_winner"] = nobel["gender"] == "female"
# Calculate the decade for each Nobel Prize award
nobel["decade"] = nobel["awardYear"] // 10 * 10
# Compute the proportion of female winners for each decade and category
prop_female_winners = nobel.groupby(["decade", "category"], as_index=False)["female_winner"].mean()
# Plot the proportion of female winners per decade by categories
plt.figure(figsize=(10, 5))
sns.barplot(x="decade", y="female_winner", hue="category", data=prop_female_winners)
plt.title("The proportion of female winners per decade by categories")
plt.ylabel("Female winners ratio")
plt.xlabel("Decade")
plt.legend(loc="upper left")
plt.show()
Mark tasks as Completed
Was alles duidelijk?
Bedankt voor je feedback!
Sectie 1. Hoofdstuk 4
Vraag AI
Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.