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!
df = pd.read_csv('data/nobel.csv')
print(df.head())
print(df.describe())
print(df.columns)import pandas as pd
import seaborn as sns
import numpy as np
# Display first few rows
print("The header rows are:")
print(df.head())
print("\n")
print("The dataset information is:")
# Display dataset information
print(df.info())
print("\n")
print("The summary statistics are:")
# Display summary statistics
print(df.describe())
print("\n")
print("Checking for missing values and dataset shape:")
# Check for missing values
print(df.isnull().sum())
print("\n")
print("Column names and shape of the dataset:")
#print column names
print(df.columns)
print("\n")
print("The shape of the dataset is:")
#print the shape of the dataframe
print(df.shape)
print(df.groupby('birth_country').count())print(df.groupby('birth_country').count().sort_values('year', ascending = False))print(df.groupby('sex').count().sort_values('year', ascending = False))top_country = 'United States of America'
top_gender = 'Male'import numpy as np
# 1. Create a decade column
df['decade'] = (np.floor(df['year'] / 10) * 10).astype(int)
# 2. Identify US-born winners
df['usa_born'] = df['birth_country'] == 'United States of America'
# 3. Group by decade and find the mean (ratio)
ratios = df.groupby('decade')['usa_born'].mean()
# 4. Find the decade with the maximum ratio
max_decade = ratios.idxmax()
print(f"The decade with the highest ratio is: {max_decade}")max_decade_usa = max_decadedf['female_gender'] = df['sex']== 'Female'
ratio_decade_category_female_mean = df.groupby(['decade', 'category'])['female_gender'].mean()
max_female_dict = ratio_decade_category_female_mean.idxmax()
max_female_dict = {2020 : 'Literature' }
print(max_female_dict)# Filter the full dataframe first, then select the columns you want
first_woman_category = df.query("female_gender == 1")[['year','full_name','category']]
#print(first_woman_category.head(1))
first_woman_name = first_woman_category.iloc[0,1]
first_woman_category = first_woman_category.iloc[0,2]
print(first_woman_name)
print(first_woman_category)
df.columns#list_repeat= df.groupby(['full_name', 'organization_name']).count()
list_repeat= df.groupby(['full_name']).count()
list_repeat_more_than_one = list_repeat.query('prize > 1')
list_repeat_more_than_one = list_repeat_more_than_one.index
print(list_repeat_more_than_one)repeat_list = list(list_repeat_more_than_one )
print(repeat_list)