Last active
June 1, 2020 03:04
-
-
Save iangelmx/da92cb1287af668942fd87e5a0bc63cb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Hacemos que la columna Entity sea un índice | |
f_2 = filtered.set_index('Entity') | |
# Volvemos a filtrar, pero ahora los países potencia junto con México | |
power_countries = f_2.loc[ ['Mexico', 'United States' , | |
'United Kingdom', 'Russia', | |
'South Korea'] ] | |
#Creamos una Pivot table que sume todas las pruebas de cada país | |
table = pd.pivot_table( | |
power_countries, | |
values = 'New tests', | |
index = ['Entity'], | |
aggfunc=sum, | |
fill_value=0 | |
).sort_values(by='New tests', ascending=True) | |
#Cambiamos el nombre de la columna New test a Pruebas | |
table = table.rename(columns={ 'New tests':'Pruebas' }) | |
table |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment