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 required libraries
import pandas as pd
import seaborn as sns
import numpy as np
import matplotlib.pyplot as plt
# Reading the CSV file
nobel_price = pd.read_csv('data/nobel.csv')
# Finding the top gender and top country
top_gender = nobel_price['sex'].value_counts().index[0]
top_country = nobel_price['birth_country'].value_counts(ascending=False).index[0]
print("Top Gender:", top_gender)
print("Top Country:", top_country)
# Creating a 'US_born' column to flag individuals born in the USA
nobel_price['US_born'] = nobel_price['birth_country'] == 'United States of America'
# Creating a 'decade' column to group years into decades
nobel_price['decade'] = (np.floor(nobel_price['year'] / 10) * 10).astype(int)
# Grouping by 'decade' and calculating the mean of 'US_born'
decade_usa = nobel_price.groupby('decade', as_index=False)['US_born'].mean().sort_values('US_born', ascending=False)
# Finding the decade with the highest mean of US-born winners
max_decade_usa = int(decade_usa.iloc[0]['decade'])
# Printing the results
print(max_decade_usa)
sns.relplot(x='decade', y='US_born', data=decade_usa, kind='line')
plt.show()
# Adding a column to indicate if the Nobel Prize winner is female
nobel_price['female_winner'] = nobel_price['sex'] == 'Female'
# Grouping by 'decade' and 'category' and calculating the mean of 'female_winner'
female_winners_mean = nobel_price.groupby(['decade', 'category'], as_index=False)['female_winner'].mean().sort_values('female_winner', ascending=False)
# Finding the row with the highest mean of female winners
max_female_winners = female_winners_mean[female_winners_mean['female_winner'] == female_winners_mean['female_winner'].max()]
# Saving the decade and category values
decade = max_female_winners.iloc[0]['decade']
category = max_female_winners.iloc[0]['category']
# Creating a dictionary with the decade and category values
max_female_dict = {decade:category}
# Printing the results
print(max_female_dict)
# Finding the name of the first woman to win a Nobel Prize
first_woman_name = nobel_price[nobel_price['female_winner'] == True].sort_values('year', ascending=True).iloc[0]['full_name']
# Printing the name of the first woman to win a Nobel Prize
print("The first woman to win a Nobel Prize:", first_woman_name)
# Calculating the value counts for 'full_name'
name_counts = nobel_price['full_name'].value_counts()
# Filtering names that appear two or more times
names_appearing_twice_or_more = name_counts[name_counts >= 2].index
repeat_list = list(names_appearing_twice_or_more)
print(repeat_list)