REALIZADO POR JARINSON CASTRO - DATA ANALYST
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!
# Carga de Librerías
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as npnobel = pd.read_csv("data/nobel.csv")
nobel = pd.DataFrame(nobel)
nobelPRIMERA PREGUNTA: ¿QUÉ GENERO Y PAÍS ES EL MÁS PREMIADO?
#1) What is the most commonly awarded gender and birth country?
# a) Hallamos top_gender:
nobel_in_gender = nobel.groupby("sex")["prize"].agg("count")
nobel_in_gender_order = nobel_in_gender.sort_values(ascending=False)
top_gender = nobel_in_gender_order.index[0]
print(top_gender)
# b) Hallamos top_country:
nobel_in_country = nobel.groupby("birth_country")["prize"].agg("count")
nobel_in_country_order = nobel_in_country.sort_values(ascending=False)
top_country = nobel_in_country_order.index[0]
print(top_country)SEGUNDA PREGUNTA: ¿QUÉ DÉCADA TIENE EL MAYOR RATIO DE GANADORES AMERICANOS EN TODAS LAS CATEGORÍAS?
#Which decade had the highest ratio of US-born Nobel Prize winners to total winners in all categories?
#Store this as an integer called max_decade_usa.# a) Creamos columna que identifica si el ganador es de USA:
nobel["is_american"] = nobel["birth_country"] == "United States of America"
# b) Creamos columna que identificará la década:
nobel["decade"] = (np.floor(nobel["year"]/10) * 10).astype(int)
# c) Agrupamos por décadas y sacamos el ratio de americanos ganadores:
nobel_group = nobel.groupby("decade",as_index=False)["is_american"].mean()
# d) Hallamos el máximo valor:
max_decade_usa = nobel_group[nobel_group['is_american'] == nobel_group['is_american'].max()]['decade'].values[0]
max_decade_usa#Añadimos un adicional, con un gráfico de líneas que tiene la década y el ratio.
AmericanWinners = sns.relplot(x="decade",y="is_american",data=nobel_group,kind="line")
AmericanWinners.set(xlabel="Decadas",ylabel="Winner Rate")
plt.show()TERCERA PREGUNTA: ¿QUÉ DECADA Y CATEGORÍA TIENE LA MAYOR PROPORCIÓN DE GANADORAS?
# a) Identificamos filas de ganadoras femeninas:
nobel["is_female"] = nobel["sex"] == "Female"
# b) Agrupamos la información:
female_group = nobel.groupby(["decade","category"],as_index=False)["is_female"].mean()
# c) Filtrando para hallar el ratio más alto:
female_filtered = female_group[female_group["is_female"]==female_group["is_female"].max()]
# d) Creando el diccionario:
max_female_dict = {female_filtered["decade"].values[0]:female_filtered["category"].values[0]}
max_female_dict
#Añadimos un adicional, con un gráfico de líneas separado por hue.
femalewinners = sns.relplot(x="decade",y="is_female",data=female_group,hue="category",kind="line")
femalewinners.set(xlabel="decade",ylabel="winning rate")CUARTA PREGUNTA: ¿QUIÉN FUE LA PRIMERA MUJER EN RECIBIR EL PREMIO NOBEL Y EN QUÉ CATEGORÍA?
# a) Filtramos a por ganadoras Femeninas:
female_winner = nobel[nobel["sex"]=="Female"]
# b) Filtramos por el año más antiguo:
female_winner = female_winner[female_winner["year"]==female_winner["year"].min()]
# c) Obtenemos la información
first_woman_name = female_winner["full_name"].values[0]
first_woman_category = female_winner["category"].values[0]
print(first_woman_name)
print(first_woman_category)