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

# Start coding here!
#Loading data
nobel_df=pd.read_csv('data/nobel.csv')
nobel_df.head()
#top gender and birth country
gender=nobel_df['sex'].value_counts().reset_index(name='count')
top_gender = gender.loc[gender['count'].idxmax(), 'index']
print(top_gender)

birth_country=nobel_df['birth_country'].value_counts().reset_index(name='count')
top_country=birth_country.loc[birth_country['count'].idxmax(), 'index']
print(top_country)
#Decade with highest ratio of US-born Nobel Prize Winners
USA_df=nobel_df
USA_df['Decade'] = (USA_df['year'] // 10) * 10
group_by_dec=USA_df.groupby('Decade')['birth_country'].value_counts().reset_index(name='count')
group_by_dec['proportion']=group_by_dec['count']/group_by_dec.groupby('Decade')['count'].transform('sum')
USA_df=group_by_dec[group_by_dec['birth_country']=='United States of America']

max_decade_usa=USA_df.loc[USA_df['proportion'].idxmax(),'Decade']
print(max_decade_usa)
#Relplot for USA-Born Nobel Prize Winners
sns.relplot(x='Decade', y='proportion', kind='line', data=USA_df)
plt.title('Proportion of USA-Born Nobel Prize Winners')
# Show the plot
plt.show()
new_df=nobel_df
new_df['Decade'] = (new_df['year'] // 10) * 10
new_df['female_winners']=new_df['sex']=='Female'
grouped_cat=new_df.groupby(['Decade', 'category'], as_index=False)['female_winners'].mean()
# Find the decade and category combination with the highest count for females
female_max_count = grouped_cat.loc[grouped_cat['female_winners'].idxmax()].to_dict()

# Create a dictionary with decade as key and category as value pair
max_female_dict = {female_max_count['Decade']: female_max_count['category']}
print(max_female_dict)
#Relplot for decade and category combination with count for female winners
sns.relplot(x='Decade', y='female_winners', kind='line', hue='category', data=grouped_cat)
plt.title('Proportion of Female Nobel Prize Winners by Category')
# Show the plot
plt.show()
#first woman to receive a Nobel Prize & category
female=nobel_df[nobel_df['sex']=='Female']
first_woman_name=female.iloc[0,7]
first_woman_category=female.iloc[0,1]

print(first_woman_name)
print(first_woman_category)

#Repeated winners

winners_count=nobel_df.groupby('laureate_id')['full_name'].value_counts().reset_index(name='count')
repeat_list=winners_count['full_name'][winners_count['count']>1].to_list()
print(repeat_list)