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
nobel=pd.read_csv("data/nobel.csv")
nobel.tail()import pandas as pd
import seaborn as sns
import numpy as np
nobel=pd.read_csv("data/nobel.csv")
nobel.head()
#top_gender1=nobel["sex"].value_counts()
#top_country2=nobel["birth_country"].value_counts()
top_gender=nobel["sex"].mode()[0]
top_country=nobel["birth_country"].mode()[0]
nobel["decade"] = (nobel["year"] // 10) * 10
nobel["us_born"]=nobel["birth_country"]== "United States of America"
us_agg=nobel.groupby("decade").agg(
us_born_winners=("us_born", "sum"), # Count US-born winners
total_winners=("us_born", "size") # Count total winners
).reset_index()
us_agg["us_ratio"]=us_agg["us_born_winners"]/us_agg["total_winners"].sum()
max_decade_usa = us_agg['decade'][us_agg['us_ratio'].idxmax()]
#max_decade_usa = int(decade_stats.loc[decade_stats['us_ratio'].idxmax(), 'decade']) if decade is an index in DF
print(max_decade_usa)
nobel["female_winner"]=nobel["sex"]=="Female"
prop_female=nobel.groupby(["decade", "category"])["female_winner"].mean().reset_index()
#print(prop_female)
max_female_winner=prop_female[prop_female['female_winner']==prop_female['female_winner'].max()] #[["decade", "category"]]
max_female_winner
max_female_dict = {max_female_winner['decade'].values[0]: max_female_winner['category'].values[0]}
print(top_gender)
print(top_country)
max_female_dict
first_woman=nobel[nobel["female_winner"]==True]
print(first_woman)
first_woman_name= first_woman["full_name"][first_woman["year"].idxmin()]
first_woman_category=first_woman["category"][first_woman["year"].idxmin()]
print(first_woman_name)
print(first_woman_category)
#name_counts = nobel['full_name'].value_counts()
#repeat_names = name_counts[name_counts > 1].index.tolist()
#repeat_list = repeat_names
#print(repeat_list)
# Or Create an empty list to store repeat winners
repeat_list = []
# Use a for loop to count occurrences and check for repeats
for name in nobel['full_name'].unique():
# Count the occurrences of each name
if (nobel['full_name'] == name).sum() > 1:
repeat_list.append(name)
print(repeat_list)