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!
#read the dataset
nobel_prize = pd.read_csv("data/nobel.csv")
nobel_prize.head()#Question 1
#Most common awarded gender
count_gender = nobel_prize.value_counts('sex')
print(count_gender)
top_gender = count_gender.index[0]
print('\n Most common awarded gender: ' + top_gender)
#Most common awarded country birth
count_country = nobel_prize.value_counts('birth_country')
print(count_country)
top_country = count_country.index[0]
print('\n Most common awarded country: ' + top_country)#Question 2
#creating column for winners bornd in USA
nobel_prize['US_born'] = nobel_prize['birth_country'] == 'United States of America'
#creating decade column
nobel_prize['decade'] = ((np.floor(nobel_prize['year']/10))*10).astype(int)
#group by decade
us_born = pd.DataFrame(nobel_prize.groupby('decade', as_index=False)['US_born'].mean())
print(us_born)
#max decade us
max_decade_usa = us_born[us_born['US_born'] == us_born['US_born'].max()]
max_decade_usa = max_decade_usa['decade'].values[0]
print(max_decade_usa)
#ploting
sns.relplot(x = 'decade', y = 'US_born', data = us_born, kind='line')#Question 3
#filtering nobel prize female
nobel_prize['female_winner'] = nobel_prize['sex'] == 'Female'
#grouping by decade and category
female_winner = nobel_prize.groupby(['decade', 'category'], as_index=False)['female_winner'].mean()
female_winner = female_winner[ female_winner['female_winner'] ==female_winner['female_winner'].max()]
#creating a dictionary
max_female_dict = {
female_winner['decade'].values[0]: female_winner['category'].values[0]
}
print(max_female_dict)# Question 4
# Filtering the tada frame for female winners
nobel_female = nobel_prize[nobel_prize['female_winner'] == True]
# first woman name to receive a Nobel Prize
first_woman_year = nobel_female['year'].min()
first_woman_name = nobel_female[nobel_female['year'] == first_woman_year]['full_name'].values[0]
print(first_woman_name)
# first category a woman receive a Nobel Prize
first_woman_category = nobel_female[nobel_female['year'] == first_woman_year]['category'].values[0]
print(first_woman_category)
# Question 5
# counting the repetitions of name of the winners
most_winners = nobel_prize['full_name'].value_counts()
most_winners = most_winners[most_winners >= 2].index
repeat_list = list(most_winners)
print(repeat_list)