Skip to content
The Nobel Prize has been among the most prestigious 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.
import pandas as pd 
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt

nobel_df = pd.read_csv('data/nobel.csv')
nobel_df.shape
# get an initial view of the 18 columns
nobel_df.head()

What is the most commonly awarded gender and birth country?

(Store your answers as string variables top_gender and top_country)

# count total awards for each gender
nobel_df['sex'].value_counts()
# use if logic to define variable 
gender_counts = nobel_df['sex'].value_counts()

if gender_counts['Female'] > gender_counts['Male']:
    top_gender = 'Female'
else:
    top_gender = 'Male'

print(top_gender)

Nobel Prize Winners by Gender Over Time

# create a pivot table for plotting
nobel_df.pivot_table(index='year', columns='sex', aggfunc='size', fill_value=0)

#plotting winners by gender over years
plt.figure(figsize=(10, 5))

sns.lineplot(x=gender_by_year.index, y=gender_by_year['Female'], label='Female Winners')
sns.lineplot(x=gender_by_year.index, y=gender_by_year['Male'], label='Male Winners')

plt.title("Nobel Prize Winners by Gender Over Time")
plt.xlabel("Year")
plt.ylabel("Number of Winners")
plt.grid(True)
plt.legend()
plt.tight_layout()
plt.show()
# count total awards for each birth country
nobel_df['birth_country'].value_counts().head(3)

Just learned the .idxmax series method, which seems ideal.

# select the top country by medals won
top_country = nobel_df['birth_country'].value_counts().idxmax()
print(top_country)

Which decade had the highest ratio of US-born Nobel Prize winners to total winners in all categories?

(Store this as an integer called max_decade_usa)

# we need to add a decade column, we can use each row's year awarded to determine decade with floor division
nobel_df['decade'] = (nobel_df['year'] // 10) * 10

# select a random row to check the above
nobel_df.iloc[364][['year','decade']]
# work out the total count of US winners and rest of world winners
us_count = (nobel_df['birth_country'] == 'United States of America').sum()
rest_count = (nobel_df['birth_country'] != 'United States of America').sum()

# work out the percent of US to ROW winners
us_percent = int(us_count / rest_count * 100)
print(f"American-born recipients account for {us_percent}% of all winners.")

Now lets find the strongest ratio by decade.