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 matplotlib.pyplot as plt
import numpy as np

# Start coding here!
df = pd.read_csv('data/nobel.csv')
df.head()
#What is the most commonly awarded gender and birth country?
top_gender= df.sex.value_counts().index[0]
top_country = df.birth_country.value_counts().index[0]

print(f'The most commonly awarded sex is {top_gender} and the most commonly awarded birth country is {top_country}')
#Which decade had the highest ratio of US-born Nobel Prize winners to total winners in all categories?

df['us_born'] = df['birth_country'] == "United States of America"

decade = np.floor(df['year']/10)*10
decade_int = decade.astype('int')
df['decade'] = decade_int

decade_df = df.groupby('decade', as_index=False)['us_born'].mean() #By setting as_index=False, you make sure the result is saved as a DataFrame rather than a series.

high_ratio = decade_df['us_born'].max()

max_decade_df = decade_df[decade_df['us_born'] == high_ratio]

# Extract the decade value from the filtered DataFrame
max_decade_usa = max_decade_df['decade'].values[0]

print(f'The decade with the highest ratio of US-born Nobel Prize winners to total winners was {max_decade_usa}')
sns.relplot(x='decade', y='us_born', data=decade_df, kind='line')
#Which decade and Nobel Prize category combination had the highest proportion of female laureates?

df['female'] = df['sex'] == "Female"

decade_category_df = df.groupby(['decade', 'category'], as_index=False)["female"].mean()

high_fem_ratio = decade_category_df[['female']].max()
df2= decade_category_df[decade_category_df.female.isin(high_fem_ratio)]

max_female_dict = {df2['decade'].values[0]: df2['category'].values[0]}

for key, value in max_female_dict.items():
    key= key
    value= value

print(f'The decade and Nobel Prize category combination that had the highest proportion of female laureates was {key} and {value}')

sns.relplot(x='decade', y='female', data=decade_category_df, kind='line', hue='category')
#Who was the first woman to receive a Nobel Prize, and in what category?
fem_df = df.query('sex == "Female"')
fem_df.sort_values(by='year')

first_woman_name = fem_df.iloc[0]['full_name']
first_woman_category = fem_df.iloc[0]['category']

print(f'The first woman to receive a Nobel Prize was {first_woman_name} in the category {first_woman_category}')
#Which individuals or organizations have won more than one Nobel Prize throughout the years?

repeat_list = []

name_counts = df['full_name'].value_counts()

name_counts = name_counts[name_counts >=2].index

for name in name_counts:
     repeat_list.append(name)
        
print(repeat_list)