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!
novel = pd.read_csv('data/nobel.csv')
# We skip the birthdate data which are not formatted correctly
novel = novel[~novel['birth_date'].str.contains('-00-', na=False)]
# we determine the range for the decade taking the max birthdate and the min birthdate with the year
decade_year = pd.to_datetime(novel['birth_date']).dt.year
decade_year = (decade_year // 10) * 10
novel['decade_birth_date'] = decade_year
novel['decade_year_laureated'] = (novel['year'] // 10) * 10
# most commonly awarded gender and bith country
count_gender = novel.groupby('sex').count()
count_country = novel.groupby('birth_country').count()
top_gender = count_gender.idxmax().iloc[0]
top_country = count_country.idxmax().iloc[0]
# which decade -> highest ratio of US-born Nobel Prize winner to total winner in all categories
# count all the data
total_winner = novel['laureate_id'].count()
US_born_winners = novel.loc[novel['birth_country'] == 'United States of America']
US_born_winners_by_decade = US_born_winners.groupby('decade_year_laureated')['laureate_id'].agg('count').reset_index()
max_decade_usa = US_born_winners_by_decade.loc[US_born_winners_by_decade['laureate_id'] == US_born_winners_by_decade['laureate_id'].max(), 'decade_year_laureated'].iloc[0]
max_decade_usa = int(max_decade_usa)
# Which decade and Nobel prize category had the highest proportions of female laureates
female_laureates_df = novel.loc[novel['sex'] == 'Female']
grouped_decade_female_nobel_prize = female_laureates_df.groupby(['category', 'decade_year_laureated'])['sex'].count().reset_index()
grouped_decade_nobel_prize = novel.groupby(['category', 'decade_year_laureated'])['sex'].count().reset_index()
# divide the number of female for each category and decade by the total number of laureate for each cat and decade
grouped_decade_female_nobel_prize = grouped_decade_female_nobel_prize.merge(grouped_decade_nobel_prize, on=['category', 'decade_year_laureated'], suffixes=('_female', '_total'))
grouped_decade_female_nobel_prize['proportion_female_laureate'] = grouped_decade_female_nobel_prize['sex_female'] / grouped_decade_female_nobel_prize['sex_total']
# set the max female dict to an object
max_female_dict = {}
max_female = grouped_decade_female_nobel_prize.loc[grouped_decade_female_nobel_prize['proportion_female_laureate'] == grouped_decade_female_nobel_prize['proportion_female_laureate'].max(), ['category', 'decade_year_laureated']]
max_female_dict = {
max_female['decade_year_laureated'].iloc[0] : max_female['category'].iloc[0]
}
# the first woman to receive a nobel prize
# we can reuse the female_laureate_df
first_woman = female_laureates_df.loc[female_laureates_df['year'] == female_laureates_df['year'].min()]
first_woman_name = str(first_woman['full_name'].iloc[0])
first_woman_category = str(first_woman['category'].iloc[0])
# which individuals have won more than one nobel prizes
# pivot table with count laureate_id by full_name
repeat_list = []
year_repeated_number_laureates = novel.groupby('full_name')['laureate_id'].agg('count').reset_index(name='count_laureates')
novel = novel.merge(year_repeated_number_laureates, on='full_name')
print(year_repeated_number_laureates)
for index, rows in novel.iterrows():
if rows['count_laureates'] >= 2:
if rows['full_name'] not in repeat_list:
repeat_list.append(rows['full_name'])
print(repeat_list)
novel.tail()