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
df = pd.read_csv("data/nobel.csv")
df.head()# Most awarded gender and birth country
top_gender = df["sex"].value_counts().index[0]
top_country = df['birth_country'].value_counts().index[0]
print(top_gender)
print(top_country)df['US-born_winners'] = df['birth_country']=="United States of America"
df["decade"] = (np.floor(df["year"]/10)*10).astype(int)
ratio_by_decade = df.groupby('decade', as_index=False)['US-born_winners'].mean()
# Identify the decade with the highest ratio of US-born winners
max_ratio_decade = ratio_by_decade[ratio_by_decade['US-born_winners'] == ratio_by_decade['US-born_winners'].max()]['decade'].values[0]
max_decade_usa = max_ratio_decade
max_decade_usa# relational line plot
sns.relplot(x="decade", y='US-born_winners', kind='line', data=df)df.head()# Filtering for female winners
df['female_winner'] = df["sex"]=="Female"
df.head()# Group by decade and category, calculate the mean of female_winner
grouped_data = df.groupby(['decade', 'category'], as_index=False)['female_winner'].mean()
# Print the result
print(grouped_data)# Find the row with the highest mean female winners
max_mean_row = grouped_data[grouped_data['female_winner'] == grouped_data['female_winner'].max()]
# Save the decade and category values
max_decade_category = max_mean_row[['decade', 'category']].values[0]
print("Decade and Category with the Highest Female Winners:")
print(max_decade_category)max_female_dict = {max_decade_category[0]: max_decade_category[1]}
max_female_dict# relational line plot
sns.relplot(x="decade", y='US-born_winners', kind='line', data=df, hue='category')# Filter the DataFrame for female winners
female_winners_df = df[df['female_winner'] > 0]
# Find the earliest year and corresponding category
earliest_row = female_winners_df[female_winners_df['decade']==female_winners_df['decade'].min()]
# Extract the name and category
first_woman_name = earliest_row['full_name'].iloc[0]
first_woman_category = earliest_row['category'].iloc[0]
print("First Woman to Win a Nobel Prize:")
print(f"Name: {first_woman_name}")
print(f"Category: {first_woman_category}")counts = df['full_name'].value_counts()
# Select winners with counts of two or more
repeat_list = list(counts[counts >= 2].index)
repeat_list