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
# Load dataframe
df = pd.read_csv("./data/nobel.csv")# Check dataframe info
df.info()# Preview dataframe first rows
df.head()# Find the most commonly awarded gender
top_gender = df["sex"].value_counts().index[0]
print(top_gender)# Find the most commonly awarded birth country
top_country = df["birth_country"].value_counts().index[0]
print(top_country)# Create the US-born winners column
df["us_born_winners"] = df["birth_country"] == "United States of America"
# Create the decade column
df["decade"] = (np.floor(df["year"] / 10) * 10).astype(int)
# Find the US-born winners ratio by decade
us_born_ratio_by_decade = df.groupby("decade")["us_born_winners"].mean()
# Identify the decade with the highest ratio of US-born winners
max_decade_usa = us_born_ratio_by_decade.idxmax()
print(max_decade_usa)# Set the style and context of the plot
sns.set(style="whitegrid", context="paper")
# Set the figure size of the plot
plt.figure(figsize=(12, 6))
# Create a relational line plot of the US-born winners by decade
sns.lineplot(x="decade", y="us_born_winners", data=df, palette="tab10", marker="o")
# Add title and labels
plt.title("Proportion of US-born winners by Decade")
plt.xlabel("Decade")
plt.ylabel("Proportion of US-born Winners")
# Show the plot
plt.show()# Add a column to identify female winners
df["female_winners"] = df["sex"] == "Female"
# Find the female winners ratio by decade and category
female_ratio_by_decade_category = df.groupby(["decade", "category"])["female_winners"].mean()
# Identify the decade and category with the highest proportion of female winners
max_decade_category_female = female_ratio_by_decade_category.idxmax()
# Store the result as a dictionary
max_female_dict = {max_decade_category_female[0]: max_decade_category_female[1]}
print(max_female_dict)# Set the style and context of the plot
sns.set(style="whitegrid", context="paper")
# Set the figure size of the plot
plt.figure(figsize=(12, 6))
# Create a relational line plot of the female winners by decade and category
sns.lineplot(x="decade", y="female_winners", data=df, hue="category", palette="tab10", marker="o")
# Add title and labels
plt.title("Proportion of Female Winners by Decade and Category")
plt.xlabel("Decade")
plt.ylabel("Proportion of Female Winners")
# Show the plot
plt.show()# Subset the dataframe with only female winners
female_winners_df = df[df["female_winners"]]
# Find the first female to receive a Nobel prize
first_female_winner = female_winners_df.sort_values("year").iloc[0]
# Extract the name of the first female winner
first_woman_name = first_female_winner["full_name"]
print(first_woman_name)# Extract the category of the first female winner
first_woman_category = first_female_winner["category"]
print(first_woman_category)# Count the number of times each winner has won
winner_count = df["full_name"].value_counts()
# Extract the list of repeat winners
repeat_list = list(winner_count[winner_count >= 2].index)
print(repeat_list)