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 data 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 libraries
import pandas as pd
import seaborn as sns
import numpy as np
import matplotlib.pyplot as plt
# Start coding here!
nobel_df = pd.read_csv("data/nobel.csv")
#print(nobel_df.head())
top_gender = nobel_df["sex"].value_counts().idxmax()
top_country = nobel_df["birth_country"].value_counts().idxmax()What is the most commonly awarded gender and birth country?
g = sns.catplot(x="sex", data=nobel_df, kind="count", palette={"Male":"Blue", "Female":"Purple"})
g.fig.suptitle("Nobel awards by Gender")
plt.show()
print("Highest awarded gender: ", top_gender)top_10_df = (
    nobel_df["birth_country"]
    .value_counts()
    .head(10)
    .reset_index()
)
top_10_df.columns = ['birth_country', 'count']
g = sns.catplot(x="birth_country", y="count", data=top_10_df, kind="bar", hue="count")
g.fig.suptitle("Nobel awards by Birth Country")
plt.xticks(rotation=90)
plt.show()
print("Highest awarded Birth Country: ", top_country)Which decade had the highest ratio of US-born Nobel Prize winners to total winners in all categories?
nobel_df['decade'] = (nobel_df['year'] // 10) * 10
us_born_winners = nobel_df[nobel_df['birth_country'] == "United States of America"][
    ['laureate_id', 'decade']
]
us_winners_per_decade = (
    us_born_winners
    .groupby('decade')
    .size()
    .reset_index(name='us_winners')
)
total_winners_per_decade = (
    nobel_df
    .groupby('decade')
    .size()
    .reset_index(name='total_winners')
)
winners_per_decade = pd.merge(us_winners_per_decade, total_winners_per_decade, on='decade', how='left')
winners_per_decade['us_ratio'] = winners_per_decade['us_winners'] / winners_per_decade['total_winners']
max_decade_usa = winners_per_decade.loc[winners_per_decade['us_ratio'].idxmax(), 'decade']g = sns.relplot(x='decade', y='us_ratio', data=winners_per_decade, kind="line")
g.fig.suptitle("Ratio of US-born Nobel Prize winners per Decade", y=1.03)
plt.show()
print(f"π During the {max_decade_usa}s, the proportion of US-born Nobel laureates was at its peak.")Which decade and Nobel Prize category combination had the highest proportion of female laureates?
female_winners = nobel_df[nobel_df['sex'] == "Female"][
['laureate_id','decade','category']]
total_female_winners_per_decade = (
    female_winners
    .groupby(['decade', 'category'])
    .size()
    .reset_index(name='female_winners')
)
total_winners_per_decade_cat = (
    nobel_df
    .groupby(['decade', 'category'])
    .size()
    .reset_index(name='total_winners')
)
winners_per_decade = pd.merge(total_female_winners_per_decade, total_winners_per_decade_cat, on=('decade', 'category'), how='left')
winners_per_decade['female_ratio'] = winners_per_decade['female_winners'] / winners_per_decade['total_winners']
max_female_row = total_female_winners_per_decade.loc[winners_per_decade['female_ratio'].idxmax()]
max_female_dict = {
    max_female_row['decade'] : max_female_row['category']
}pivot_df = winners_per_decade.pivot(
    index='decade',
    columns='category',
    values='female_ratio'
).fillna(0)
colors = sns.color_palette("Set2", n_colors=len(pivot_df.columns))
pivot_df.plot(kind='bar', stacked=True, color=colors, figsize=(10, 6))
plt.title("Female Nobel Prize Winners per Decade by Category")
plt.xlabel("Decade")
plt.ylabel("Female Ratio")
plt.legend(title="Category")
plt.tight_layout()
plt.show()
decade, category = list(max_female_dict.items())[0]
print(f"π In the {decade}s, the '{category}' category had the highest proportion of female Nobel Prize winners.")Who was the first woman to receive a Nobel Prize, and in what category?
female_winners = nobel_df[nobel_df['sex'] == "Female"][
['laureate_id','full_name', 'year','category']]
first_female_winner = female_winners.sort_values('year').head(1)
first_woman_name = first_female_winner['full_name'].iloc[0]
first_woman_category = first_female_winner['category'].iloc[0]
print(f"π©βπ¬ The first woman to receive a Nobel Prize was {first_woman_name} in the category of {first_woman_category}.")
Which individuals or organizations have won more than one Nobel Prize throughout the years?
grouped_nobel_winners = (
    nobel_df
    .groupby('full_name')
    .size()
    .reset_index(name='nr_wins')
)
more_than_1_win = grouped_nobel_winners[grouped_nobel_winners['nr_wins'] > 1]
repeat_list = more_than_1_win['full_name'].tolist()
print(repeat_list)β
β