The Nobel Prize has been among the most prestigious international awards since 1901. Each year, awards are bestowed in chemistry, literature, physics, physiology or medicine, economics, and peace. In addition to the honor, prestige, and substantial prize money, the recipient also gets a gold medal with an image of Alfred Nobel (1833 - 1896), who established the prize.
The Nobel Foundation has made a dataset available of all prize winners from the outset of the awards from 1901 to 2023. The dataset used in this project is from the Nobel Prize API and is available in the nobel.csv file in the datasets folder.
In this project, you’ll get a chance to explore and answer several questions related to this prizewinning data. And we encourage you then to explore further questions that you’re interested in!
# Loading in required librariesimport pandas as pdimport seaborn as snsimport numpy as np# Start coding here!nobel = pd.read_csv("datasets/nobel.csv")nobel.columns
What decade and category pair had the highest proportion of female laureates? Store this as a dictionary called max_female_dict where the decade is the key and the category is the value.
# Calculating the proportion of female laureates per decadenobel['female_winner'] = nobel.sex=='Female'prop_female_winners = nobel.groupby(['decade','category'],as_index=False)['female_winner'].mean()prop_female_winners.sort_values("female_winner",ascending=False,inplace=True)prop_female_winners
/var/folders/53/yp3kynfd7rn5y13c2wwfm33rmgtrfb/T/ipykernel_38970/3855593822.py:2: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
nobel_female_only.sort_values("year",ascending=True,inplace=True)
Comité international de la Croix Rouge (International Committee of the Red Cross)
3
Office of the United Nations High Commissioner for Refugees (UNHCR)
2
Frederick Sanger
2
Linus Carl Pauling
2
John Bardeen
2
Marie Curie, née Sklodowska
2
repeat_list =list(nobel_by_name.index)
repeat_list
['Comité international de la Croix Rouge (International Committee of the Red Cross)',
'Office of the United Nations High Commissioner for Refugees (UNHCR)',
'Frederick Sanger',
'Linus Carl Pauling',
'John Bardeen',
'Marie Curie, née Sklodowska']
Solution provided by DataCamp
# Loading in required librariesimport pandas as pdimport seaborn as snsimport numpy as np# Read in the Nobel Prize datanobel = pd.read_csv('datasets/nobel.csv')# Store and display the most commonly awarded gender and birth country in requested variablestop_gender = nobel['sex'].value_counts().index[0]top_country = nobel['birth_country'].value_counts().index[0]print("\n The gender with the most Nobel laureates is :", top_gender)print(" The most common birth country of Nobel laureates is :", top_country)# Calculate the proportion of USA born winners per decadenobel['usa_born_winner'] = nobel['birth_country'] =='United States of America'nobel['decade'] = (np.floor(nobel['year'] /10) *10).astype(int)prop_usa_winners = nobel.groupby('decade', as_index=False)['usa_born_winner'].mean()# Identify the decade with the highest proportion of US-born winnersmax_decade_usa = prop_usa_winners[prop_usa_winners['usa_born_winner'] == prop_usa_winners['usa_born_winner'].max()]['decade'].values[0]# Optional: Plotting USA born winnersax1 = sns.relplot(x='decade', y='usa_born_winner', data=prop_usa_winners, kind="line")# Calculating the proportion of female laureates per decadenobel['female_winner'] = nobel['sex'] =='Female'prop_female_winners = nobel.groupby(['decade', 'category'], as_index=False)['female_winner'].mean()# Find the decade and category with the highest proportion of female laureatesmax_female_decade_category = prop_female_winners[prop_female_winners['female_winner'] == prop_female_winners['female_winner'].max()][['decade', 'category']]# Create a dictionary with the decade and category pairmax_female_dict = {max_female_decade_category['decade'].values[0]: max_female_decade_category['category'].values[0]}# Optional: Plotting female winners with % winners on the y-axisax2 = sns.relplot(x='decade', y='female_winner', hue='category', data=prop_female_winners, kind="line")# Finding the first woman to win a Nobel Prizenobel_women = nobel[nobel['female_winner']]min_row = nobel_women[nobel_women['year'] == nobel_women['year'].min()]first_woman_name = min_row['full_name'].values[0]first_woman_category = min_row['category'].values[0]print(f"\n The first woman to win a Nobel Prize was {first_woman_name}, in the category of {first_woman_category}.")# Selecting the laureates that have received 2 or more prizescounts = nobel['full_name'].value_counts()repeats = counts[counts >=2].indexrepeat_list =list(repeats)print("\n The repeat winners are :", repeat_list)
The gender with the most Nobel laureates is : Male
The most common birth country of Nobel laureates is : United States of America
The first woman to win a Nobel Prize was Marie Curie, née Sklodowska, in the category of Physics.
The repeat winners are : ['Comité international de la Croix Rouge (International Committee of the Red Cross)', 'Linus Carl Pauling', 'John Bardeen', 'Frederick Sanger', 'Marie Curie, née Sklodowska', 'Office of the United Nations High Commissioner for Refugees (UNHCR)']