Skip to content

Instantly share code, notes, and snippets.

@ricardocabral
Created April 13, 2014 22:30
Show Gist options
  • Save ricardocabral/10605014 to your computer and use it in GitHub Desktop.
Save ricardocabral/10605014 to your computer and use it in GitHub Desktop.
{
"metadata": {
"name": "",
"signature": "sha256:a45893b2413cbc4e3bbfe588a3fee6010c22663dbcb717f576a0d9bea722754d"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Dados da [Social Progress Index](http://www.socialprogressimperative.org/data/spi). Tirei a mediana de cada crit\u00e9rio entre todos os paises e ordenei os crit\u00e9rios pela diferen\u00e7a percentual absoluta do Brasil em rela\u00e7\u00e3o \u00e0 mediana.\n",
"\n",
"Diferen\u00e7a positiva \u00e9 porque o Brasil tem um valor acima da mediana, o que n\u00e3o necessariamente \u00e9 bom, depende do crit\u00e9rio.\n",
"\n",
"*Number of globally ranked universities* d\u00e1 um valor indefinido pois a mediana mundial \u00e9 0 (n\u00e3o estamos t\u00e3o mal assim, o Brasil tem 2)"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"import pandas\n",
"xl_file = pandas.ExcelFile('2014 Social Progress Index Scores and Raw Data.xlsx')\n",
"dfs = {sheet_name: xl_file.parse(sheet_name) for sheet_name in xl_file.sheet_names}\n",
"df=dfs['Index data']\n",
"medians = df.median()\n",
"brazil = df.loc['Brazil']\n",
"diff = 100*(brazil-medians)/medians\n",
"diff_abs = abs(diff)\n",
"dfbr = pandas.DataFrame({u'Diferen\u00e7a':diff,u'Dif.abs.':diff_abs})\n",
"dfbr = dfbr.sort([u'Dif.abs.'], ascending=[0])\n",
"pandas.options.display.float_format = '{:,.1f}%'.format\n",
"del dfbr['Dif.abs.']\n",
"dfbr"
],
"language": "python",
"metadata": {},
"outputs": [
{
"html": [
"<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\">\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Diferen\u00e7a</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>Number of globally ranked universities (0=none; 5= 50)</th>\n",
" <td> inf%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Tolerance for homosexuals (0=low; 100=high)</th>\n",
" <td>210.0%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Homicide rate (1= 2/100,000; 5= 20/100,000</th>\n",
" <td>150.0%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Rural vs. urban access to improved water source (absolute difference between % of pop.)</th>\n",
" <td>120.2%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Freedom of assembly/association (0=low; 2=high)</th>\n",
" <td>100.0%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Women treated with respect (0=low; 100=high)</th>\n",
" <td>-54.8%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Indoor air pollution attributable deaths (deaths/100,000)</th>\n",
" <td>-51.9%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Inequality in the attainment of education (0=low; 1=high)</th>\n",
" <td> 42.1%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Political terror (1=low; 5=high)</th>\n",
" <td> 40.0%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Water withdrawals as a percent of resources</th>\n",
" <td>-39.5%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Personal Safety</th>\n",
" <td>-38.9%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Depth of food deficit (calories/undernourished person)</th>\n",
" <td> 37.5%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Undernourishment (% of pop.)</th>\n",
" <td> 36.6%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Traffic deaths (deaths/100,000)</th>\n",
" <td> 35.5%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Suicide rate (deaths/100,000)</th>\n",
" <td>-34.6%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Perceived criminality (1=low; 5=high)</th>\n",
" <td> 33.3%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Political rights (1=full rights; 7=no rights)</th>\n",
" <td>-33.3%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Freedom of religion (1=low; 4=high)</th>\n",
" <td> 33.3%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Level of violent crime (1=low; 5=high)</th>\n",
" <td> 33.3%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Personal Rights</th>\n",
" <td> 33.1%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Years of tertiary schooling</th>\n",
" <td>-28.6%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Private property rights (0=none; 100=full)</th>\n",
" <td> 25.0%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Upper secondary school enrollment (% of children)</th>\n",
" <td> 24.8%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Tolerance and Inclusion</th>\n",
" <td> 24.2%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Tolerance for immigrants (0=low; 100=high)</th>\n",
" <td> 23.2%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Opportunity</th>\n",
" <td> 22.1%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Access to piped water (% of pop.)</th>\n",
" <td> 21.7%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Lower secondary school enrollment (% of children)</th>\n",
" <td> 20.1%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Internet users (% of pop.)</th>\n",
" <td> 19.1%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Child mortality rate (deaths/1,000 live births)</th>\n",
" <td>-18.2%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Availability of affordable housing (% satisfied)</th>\n",
" <td>-18.2%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Ecosystem Sustainability</th>\n",
" <td> 17.6%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Mobile telephone subscriptions (subscriptions/100 people)</th>\n",
" <td> 17.5%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Greenhouse gas emissions (CO2 equivalents per GDP)</th>\n",
" <td>-16.8%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Personal Freedom and Choice</th>\n",
" <td> 15.6%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Modern slavery, human trafficking and child marriage (1=low; 100=high)</th>\n",
" <td>-15.4%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Press Freedom Index (0=most free; 100=least free)</th>\n",
" <td> 15.1%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Freedom of movement (0=low; 4=high)</th>\n",
" <td> 14.3%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Freedom over life choices (% satisfied)</th>\n",
" <td> 14.3%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Non-communicable disease deaths between the ages of 30 and 70 (probability of dying)</th>\n",
" <td>-13.0%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Satisfied demand for contraception (% of women)</th>\n",
" <td> 11.3%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Shelter</th>\n",
" <td> 11.0%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Women's average years in school</th>\n",
" <td>-10.6%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Corruption (0=high; 100=low)</th>\n",
" <td> 10.5%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Foundations of Wellbeing</th>\n",
" <td> 10.2%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Social Progress Index</th>\n",
" <td> 9.6%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Maternal mortality rate (deaths/100,000 live births)</th>\n",
" <td> -8.9%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Access to Advanced Education</th>\n",
" <td> -8.8%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Community safety net (0=low; 100=high)</th>\n",
" <td> 8.5%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Access to Information and Communications</th>\n",
" <td> 8.3%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Access to improved sanitation facilities (% of pop.)</th>\n",
" <td> -8.2%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Deaths from infectious diseases (deaths/100,000)</th>\n",
" <td> 7.2%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Biodiversity and habitat (0=no protection; 100=high protection)</th>\n",
" <td> 5.2%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Access to Basic Knowledge</th>\n",
" <td> 4.3%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Basic Human Needs</th>\n",
" <td> -4.1%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Adult literacy rate (% of pop. aged 15+)</th>\n",
" <td> -3.6%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Health and Wellness</th>\n",
" <td> 3.0%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Obesity rate (% of pop.)</th>\n",
" <td> 2.6%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Discrimination and violence against minorities (0=low; 10=high)</th>\n",
" <td> -1.7%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Primary school enrollment (% of children)</th>\n",
" <td> 1.4%</td>\n",
" </tr>\n",
" <tr>\n",
" <th></th>\n",
" <td>...</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>75 rows \u00d7 1 columns</p>\n",
"</div>"
],
"metadata": {},
"output_type": "pyout",
"prompt_number": 9,
"text": [
" Diferen\u00e7a\n",
"Number of globally ranked universities (0=none; 5= 50) inf%\n",
"Tolerance for homosexuals (0=low; 100=high) 210.0%\n",
"Homicide rate (1= 2/100,000; 5= 20/100,000 150.0%\n",
"Rural vs. urban access to improved water source (absolute difference between % of pop.) 120.2%\n",
"Freedom of assembly/association (0=low; 2=high) 100.0%\n",
"Women treated with respect (0=low; 100=high) -54.8%\n",
"Indoor air pollution attributable deaths (deaths/100,000) -51.9%\n",
"Inequality in the attainment of education (0=low; 1=high) 42.1%\n",
"Political terror (1=low; 5=high) 40.0%\n",
"Water withdrawals as a percent of resources -39.5%\n",
"Personal Safety -38.9%\n",
"Depth of food deficit (calories/undernourished person) 37.5%\n",
"Undernourishment (% of pop.) 36.6%\n",
"Traffic deaths (deaths/100,000) 35.5%\n",
"Suicide rate (deaths/100,000) -34.6%\n",
"Perceived criminality (1=low; 5=high) 33.3%\n",
"Political rights (1=full rights; 7=no rights) -33.3%\n",
"Freedom of religion (1=low; 4=high) 33.3%\n",
"Level of violent crime (1=low; 5=high) 33.3%\n",
"Personal Rights 33.1%\n",
"Years of tertiary schooling -28.6%\n",
"Private property rights (0=none; 100=full) 25.0%\n",
"Upper secondary school enrollment (% of children) 24.8%\n",
"Tolerance and Inclusion 24.2%\n",
"Tolerance for immigrants (0=low; 100=high) 23.2%\n",
"Opportunity 22.1%\n",
"Access to piped water (% of pop.) 21.7%\n",
"Lower secondary school enrollment (% of children) 20.1%\n",
"Internet users (% of pop.) 19.1%\n",
"Child mortality rate (deaths/1,000 live births) -18.2%\n",
"Availability of affordable housing (% satisfied) -18.2%\n",
"Ecosystem Sustainability 17.6%\n",
"Mobile telephone subscriptions (subscriptions/100 people) 17.5%\n",
"Greenhouse gas emissions (CO2 equivalents per GDP) -16.8%\n",
"Personal Freedom and Choice 15.6%\n",
"Modern slavery, human trafficking and child marriage (1=low; 100=high) -15.4%\n",
"Press Freedom Index (0=most free; 100=least free) 15.1%\n",
"Freedom of movement (0=low; 4=high) 14.3%\n",
"Freedom over life choices (% satisfied) 14.3%\n",
"Non-communicable disease deaths between the ages of 30 and 70 (probability of dying) -13.0%\n",
"Satisfied demand for contraception (% of women) 11.3%\n",
"Shelter 11.0%\n",
"Women's average years in school -10.6%\n",
"Corruption (0=high; 100=low) 10.5%\n",
"Foundations of Wellbeing 10.2%\n",
"Social Progress Index 9.6%\n",
"Maternal mortality rate (deaths/100,000 live births) -8.9%\n",
"Access to Advanced Education -8.8%\n",
"Community safety net (0=low; 100=high) 8.5%\n",
"Access to Information and Communications 8.3%\n",
"Access to improved sanitation facilities (% of pop.) -8.2%\n",
"Deaths from infectious diseases (deaths/100,000) 7.2%\n",
"Biodiversity and habitat (0=no protection; 100=high protection) 5.2%\n",
"Access to Basic Knowledge 4.3%\n",
"Basic Human Needs -4.1%\n",
"Adult literacy rate (% of pop. aged 15+) -3.6%\n",
"Health and Wellness 3.0%\n",
"Obesity rate (% of pop.) 2.6%\n",
"Discrimination and violence against minorities (0=low; 10=high) -1.7%\n",
"Primary school enrollment (% of children) 1.4%\n",
" ...\n",
"\n",
"[75 rows x 1 columns]"
]
}
],
"prompt_number": 9
}
],
"metadata": {}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment