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!
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
# Load Nobel Prize data from the CSV file
df = pd.read_csv("data/nobel.csv")
df.head()
# Identify the most common gender and birth country
top_gender = df["sex"].value_counts().idxmax()
top_country = df["birth_country"].value_counts().idxmax()
print(top_country)#proportion of USA winner
df['usa_born'] = df['birth_country'] == 'United States of America'
df['decade'] = (np.floor(df['year'] / 10) * 10).astype('int64')
us_born_winners_per_decade = df.groupby('decade')['usa_born'].sum()
total_winners_per_decade = df.groupby('decade')['usa_born'].count()
# Calculate the proportion of USA-born winners to total winners per decade
proportion_usa_born_per_decade = us_born_winners_per_decade / total_winners_per_decade
# Find the decade with the highest ratio of USA-born winners
highest_ratio_decade = proportion_usa_born_per_decade.idxmax()
# Find the decade value from the row with the highest ratio
max_decade_usa = df.loc[df['decade'] == highest_ratio_decade, 'decade'].iloc[0]
import matplotlib.pyplot as plt
sns.relplot(x="decade", y="usa_born", data=us_born_winners_per_decade.to_frame(), kind='line')
plt.show()#highest proportion of female laureates
# Filter the DataFrame to get entries where sex is Female
women_winners = df[df['sex'] == 'Female']
df["fem_ale"] = df['sex'] == 'Female'
# Find the earliest year a woman won
earliest_year = women_winners['year'].min()
# Get the category of the earliest year
earliest_women_per_decade = women_winners.groupby((women_winners['year'] // 10) * 10)['year'].min()
# Create the dictionary with the corrected decade keys
max_female_dict = {decade: women_winners.loc[women_winners['year'] == year, 'category'].iloc[0] for decade, year in earliest_women_per_decade.items()}
# Print the dictionary for debugging purposes
print(max_female_dict)women_winners.head()sns.relplot(x="decade", y="fem_ale", data=df, hue="category", kind="line")
# Filter the DataFrame for female winners
women_winners = df[df['sex'] == 'Female']
# Find the earliest female Nobel Prize winner
first_woman_name = women_winners.nsmallest(n=1, columns='year')['full_name'].iloc[0]
# Get the category of the earliest female Nobel Prize winner as a string
first_woman_category = women_winners.nsmallest(n=1, columns='year')['category'].iloc[0]
# Identify repeated winners
repeat_winners = df['full_name'].value_counts()
repeat_list = repeat_winners[repeat_winners >= 2].index.tolist()repeat_winners.info()sns.catplot(x="index", y="full_name", data=repeat_winners.reset_index(), kind="bar")FINDINGS most common awarded gender is male most common awarded country is USA decade with the highest us winner = 1950 ratio of us winners in that decade is 0.47 decade with the highest female is 1810
Earliest year with a female winner: 1843 Name of the earliest female winner: Baroness Bertha Sophie Felicita von Suttner, née Countess Kinsky von Chinic und Tettau Corresponding category: Peace