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 # Importing matplotlib.pyplot
# Loading the datasets to find most common gender and birth country
df = pd.read_csv('data/nobel.csv')
# Check the columns of the dataframe to find the correct column names
print(df.columns)
# 1. Most Commonly Awarded Gender and Birth Country
top_gender = df['sex'].value_counts().idxmax()
top_country = df['birth_country'].value_counts().idxmax()
# 2. Decade with Highest Ratio of US-born Winners
df['US_Born'] = df['birth_country'] == 'United States of America'
df["decade"] = (df["year"] // 10) * 10
US_winners = df[df['US_Born']].groupby('decade')['laureate_id'].count()
total_winners = df.groupby("decade")["laureate_id"].count()
ratio = (US_winners / total_winners).fillna(0)
max_decade_usa = ratio.idxmax() # the decade with the highest ratio
sns.relplot(x=ratio.index, y=ratio.values, kind='line')
plt.show()
# 3. Decade and Category with Highest Proportion of Female Laureates
df["gender"] = df["sex"].str.lower()
df["female_winner"] = (df["gender"] == "female").astype(int)
df["decade"] = (df["year"] // 10) * 10
female_ratio_df = df.groupby(["decade", "category"], as_index=False)["female_winner"].mean()
female_ratio_df = female_ratio_df.sort_values(by="female_winner", ascending=False, ignore_index=True)
max_female_row = female_ratio_df.iloc[0]
max_female_dict = {int(max_female_row["decade"]): max_female_row["category"]}
# Print the result
print(max_female_dict)
#relational plot
sns.set_style("whitegrid")
g = sns.relplot(x="decade", y="female_winner", data=female_ratio_df, kind='line', hue="category", marker="o")
g.fig.suptitle("Proportion of Female Nobel Laureates by Category Over Time")
g.set(xlabel="Decade", ylabel="Proportion of Female Winners")
plt.show()
# 4. First Woman to Win a Nobel Prize
female_winners_df = df[df["sex"].str.lower().str.strip() == "female"]
if female_winners_df.empty:
print("No female winners found in the dataset. Check the column name and values.")
first_woman_name = None
first_woman_category = None
else:
# Find the row with the earliest year
first_woman_row = female_winners_df[female_winners_df["year"] == female_winners_df["year"].min()]
# Extract the name and category
first_woman_name = first_woman_row["full_name"].values[0]
first_woman_category = first_woman_row["category"].values[0]
# Print results
print(f"First female Nobel Prize winner: {first_woman_name}")
print(f"Category: {first_woman_category}")
# 5. Individuals or Organizations with More than One Nobel Prize
repeat_list = df["full_name"].value_counts()[df["full_name"].value_counts() > 1].index.tolist()
print(f"Most awarded gender: {top_gender}")
print(f"Most awarded birth country: {top_country}")
print(f"Decade with highest ratio of US-born winners: {max_decade_usa}")
print(f"Decade and category with highest female laureate proportion: {max_female_dict}")
if first_woman_name and first_woman_category:
print(f"First woman Nobel Prize winner: {first_woman_name} in {first_woman_category}")
print(f"Repeat winners: {repeat_list}")