Skip to content

Instantly share code, notes, and snippets.

@mauroeparis
Last active June 13, 2020 15:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mauroeparis/4315d3ef9f07a0df3ad813c85de6478b to your computer and use it in GitHub Desktop.
Save mauroeparis/4315d3ef9f07a0df3ad813c85de6478b to your computer and use it in GitHub Desktop.
# %%
# Defino un a funcion para solo tener que pasar el dataset de la region
def plt_mean(dt, region):
pf_identity_graph = seaborn.lineplot(
y='pf_identity', x='year',
data=dt,
estimator=numpy.median,
label='pf_identity'
)
hf_score_graph = seaborn.lineplot(
y='hf_score', x='year',
data=dt,
estimator=numpy.median,
label='hf_score'
)
hf_score_graph.set(ylabel='', xlabel='Year')
hf_score_graph.set_title(region)
plt.show()
# %%
plt_mean(world, 'Global')
# %%
"""
2. Realicen los mismos gráficos, pero separando por regiones (Cada variable
en un gráfico distinto, sino no se ve nada). ¿La tendencia observada, es
la misma que si no dividimos por regiones?
"""
# %%
plt_mean(latam, 'Latin America & the Caribbean')
# %%
east_eu = dataset['Eastern Europe' == dataset['region']]
plt_mean(east_eu, 'Eastern Europe')
# %%
middle_east_north_af = dataset[
'Middle East & North Africa' == dataset['region']
]
plt_mean(middle_east_north_af, 'Middle East & North Africa')
# %%
sub_sahara_af = dataset['Sub-Saharan Africa' == dataset['region']]
plt_mean(middle_east_north_af, 'Sub-Saharan Africa')
# %%
cau_central_as = dataset['Caucasus & Central Asia' == dataset['region']]
plt_mean(cau_central_as, 'Caucasus & Central Asia')
# %%
oceania = dataset['Oceania' == dataset['region']]
plt_mean(oceania, 'Oceania')
# %%
wes_eu = dataset['Western Europe' == dataset['region']]
plt_mean(wes_eu, 'Western Europe')
# %%
south_as = dataset['South Asia' == dataset['region']]
plt_mean(south_as, 'South Asia')
# %%
north_am = dataset['North America' == dataset['region']]
plt_mean(north_am, 'North America')
# %%
east_as = dataset['East Asia' == dataset['region']]
plt_mean(east_as, 'East Asia')
"""
Como podemos ver la libertad de identidad personal (`pf_identity`) sufre un
declive en el año 2014 globalmente a mayor o menor escala.
Por otra parte `hf_score`, a pesar de no tener saltos abruptos en ninguna
región no tiene una tendencia mundial.
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment