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

# Start coding here!

Load the dataset and find the most common gender and birth country

Load the dataset into a DataFrame using pandas and then extract the top values from sex and birth_country.

import pandas as pd

# load data
df = pd.read_csv("data/nobel.csv")

# check
df.head()
# top value for sex and birth country 
top_gender = df.value_counts(["sex"]).index[0][0]
top_country = df.value_counts(["birth_country"]).index[0][0]

# check results 
print(top_gender)
print(top_country)

Identify the decade with the highest ratio of US-born winners

To calculate the ratio, first create a column that creates a flag for winners whose birth country is "United States of America", then create a decade column, and use both to find the ratio.

# flag for US winners
df_us = df
df_us['us_winner'] = df['birth_country'] == top_country

# check
df_us.head()
# create a decade column
df_us['decade'] = (np.floor(df_us['year'] / 10) * 10).astype(int)

# check
df_us.head()
# find the ratio
df_us = df.groupby("decade", as_index=False)["us_winner"].mean()

# check
df_us.head(13)
# decade with the highest ratio of US-born winners
max_ratio = df_us['us_winner'].max()

# filter row for year
max_row = df_us[df_us['us_winner'] == max_ratio]

# decade with highest ratio
max_decade_usa = max_row['decade'].values[0]

# check
print(max_decade_usa)
import matplotlib.pyplot as plt

# create a relational line plot
sns.relplot(kind="line",
            x="decade",
            y="us_winner",
            data=df
)

# show plot
plt.show()

Find the decade and category with the highest proportion of female laureates

Copy and modify your code from the previous tasks to create a DataFrame for the proportion of female winners, then create a dictionary called max_female_dict with the year and category pair with the most female winners.

# filtering for female winners
df_female = df
df_female['female'] = df['sex'] == 'Female'

# check
df_female.head()
# group by decade and category
df_female_grp = df_female.groupby(["decade", "category"], as_index=False)["female"].mean()

# check
df_female_grp.head()
# decade and category with the highest female winners
max_mean_win = df_female_grp['female'].max()

# get the row with the max value
max_female_win = df_female_grp[df_female_grp["female"] == max_mean_win]

# extract decade and category values
# max_female = max_female_win[['decade', 'category']].values[0]

# check 
print(max_female_win)