Nadia Rizky Hairunnisa/

Project: Visualizing the History of Nobel Prize Winners


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

Let's preview and look the general information in our dataset to better understand how we can explore it!

# Read in the data
nobel = pd.read_csv("data/nobel.csv")

# Preview the data

What is the most commonly awarded gender and birth country? 🤔 Store the string answers as top_gender and top_country.

Let's see the value occurrences of the sex and birth country columns in our noble dataset first.

# Frequency of sex column
# Frequency of birth_country column

The results above shows that males are the most commonly awarded gender, and the United States is the most commonly awarded birth country. That's not surprising, let's store the values into variables as instructed.

#Store the value with the most occurrences
top_gender = nobel['sex'].value_counts().index[0]
top_country = nobel['birth_country'].value_counts().index[0]
print("The most commonly awarded gender is", top_gender)
print("The most commonly awarded birth country is", top_country)

What decade had the highest proportion of US-born laureates? 🌎 Store this as an integer called max_decade_usa.

To answer this question, we need to determine the decade when the nobel prize laureates were rewarded, we can obtain this information from the year column. Afterward, we can examine the occurrences of each decade to determine which decade had the most US-born laureates.

# Define function to extract decade from the year
def extract_decade(year):
    return np.floor(year / 10) * 10

# Apply the function to the 'year' column
nobel['decade'] = nobel['year'].apply(lambda x: extract_decade(x))
nobel['decade'] = nobel['decade'].astype(int)
# Make a new column to filter Nobel Prize laureates born in the USA
nobel['usa_born'] = nobel['birth_country'] == 'United States of America'
# Group by decade and calculate the mean proportion of USA-born laureates
prop_usa_npl = nobel.groupby('decade')['usa_born'].agg('mean')
# Reset the index to make 'decade' a regular column
prop_usa_npl = prop_usa_npl.reset_index()
# Sort based on the proportion column that's already aggregated
prop_usa_npl.sort_values(by=['usa_born'], ascending=False)

Wow, so most US-born Nobel Prize laureates were awarded in 2000s with the proportion of 0.423. Let's store this information in an integer called 'max_decade_usa' as instructed

max_decade_usa = prop_usa_npl[prop_usa_npl['usa_born'] == prop_usa_npl['usa_born'].max()]['decade'].values[0]

print("The decade with the highest proportion of US-born laureates is", max_decade_usa)

  • AI Chat
  • Code