Skip to content

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!
file_path = 'data/nobel.csv'
nobel = pd.read_csv(file_path)

#most common sex and country
top_gender = nobel.value_counts("sex").index[0]
top_country = nobel.value_counts("birth_country").index[0]
print("Most common winner sex is:",top_gender)
print("Most common winner country is:",top_country)

#us and decades column
nobel["us_born"] = nobel["birth_country"] == "United States of America"
nobel["decade"] = (np.floor(nobel["year"] / 10) * 10).astype(int)

#most us proportion decade
nobel_means = nobel.groupby("decade", as_index=False)["us_born"].mean()
max_decade_usa = nobel_means[nobel_means["us_born"] == nobel_means["us_born"].max()]["decade"].values[0]
print("Decade with the highest proportion of US winners:",max_decade_usa)

#optional plotting
sns.set(style="whitegrid")
plt.figure(figsize=(10, 6))
plot = sns.relplot(x="decade", y="us_born", kind="line", data=nobel_means)
plt.xlabel("Decade")
plt.ylabel("Proportion of US-born Winners")
plt.title("Proportion of US-born Nobel Prize Winners Over Decades")

plt.show()

#filtering for female winners
nobel["female_winner"] = nobel["sex"] == "Female"
prop_female_winners = nobel.groupby(["decade", "category"], as_index=False)["female_winner"].mean()

max_female_decade_category = prop_female_winners[prop_female_winners["female_winner"] == prop_female_winners["female_winner"].max()][["decade", "category"]]

#creating dictionary
max_female_dict = {max_female_decade_category["decade"].values[0]: max_female_decade_category["category"].values[0]}

#optional plotting us decades vs female winners
sns.set(style="whitegrid")
plt.figure(figsize=(12, 8))
plot = sns.relplot(x="decade", y="female_winner", kind="line", hue="category", data=prop_female_winners, marker="o")
plt.xlabel("Decade")
plt.ylabel("Proportion of Female Winners")
plt.title("Proportion of Female Nobel Prize Winners Over Decades by Category")
plt.legend(title="Category", loc="upper right")

plt.show()

#findig first nobel winner woman
female_winners = nobel[nobel["sex"] == "Female"]

earliest_female_winner = female_winners.loc[female_winners['year'].idxmin()]

first_woman_name = earliest_female_winner["full_name"]
first_woman_category = earliest_female_winner["category"]
print("Earliest Female Winner:", first_woman_name)
print("Year:", earliest_female_winner["year"])
print("Category:", first_woman_category)

#repeat winners
winner_counts = nobel['full_name'].value_counts()

repeat_list = list(winner_counts[winner_counts >= 2].index)

print("Winners with Counts of Two or More (as a list):")
print(repeat_list)