|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "metadata": {}, |
| 6 | + "source": [ |
| 7 | + "# Our world in data Dataset" |
| 8 | + ] |
| 9 | + }, |
| 10 | + { |
| 11 | + "cell_type": "code", |
| 12 | + "execution_count": 1, |
| 13 | + "metadata": {}, |
| 14 | + "outputs": [], |
| 15 | + "source": [ |
| 16 | + "import pandas as pd" |
| 17 | + ] |
| 18 | + }, |
| 19 | + { |
| 20 | + "cell_type": "code", |
| 21 | + "execution_count": 2, |
| 22 | + "metadata": {}, |
| 23 | + "outputs": [ |
| 24 | + { |
| 25 | + "data": { |
| 26 | + "text/html": [ |
| 27 | + "<div>\n", |
| 28 | + "<style scoped>\n", |
| 29 | + " .dataframe tbody tr th:only-of-type {\n", |
| 30 | + " vertical-align: middle;\n", |
| 31 | + " }\n", |
| 32 | + "\n", |
| 33 | + " .dataframe tbody tr th {\n", |
| 34 | + " vertical-align: top;\n", |
| 35 | + " }\n", |
| 36 | + "\n", |
| 37 | + " .dataframe thead th {\n", |
| 38 | + " text-align: right;\n", |
| 39 | + " }\n", |
| 40 | + "</style>\n", |
| 41 | + "<table border=\"1\" class=\"dataframe\">\n", |
| 42 | + " <thead>\n", |
| 43 | + " <tr style=\"text-align: right;\">\n", |
| 44 | + " <th></th>\n", |
| 45 | + " <th>HPI Rank</th>\n", |
| 46 | + " <th>Country</th>\n", |
| 47 | + " <th>Region</th>\n", |
| 48 | + " <th>Life Expectancy (years)</th>\n", |
| 49 | + " <th>Wellbeing (0-10)</th>\n", |
| 50 | + " <th>Inequality of outcomes</th>\n", |
| 51 | + " <th>Ecological Footprint (gha/capita)</th>\n", |
| 52 | + " <th>Happy Planet Index</th>\n", |
| 53 | + " </tr>\n", |
| 54 | + " </thead>\n", |
| 55 | + " <tbody>\n", |
| 56 | + " <tr>\n", |
| 57 | + " <th>0</th>\n", |
| 58 | + " <td>1</td>\n", |
| 59 | + " <td>Costa Rica</td>\n", |
| 60 | + " <td>Americas</td>\n", |
| 61 | + " <td>79.1</td>\n", |
| 62 | + " <td>7.3</td>\n", |
| 63 | + " <td>15%</td>\n", |
| 64 | + " <td>2.8</td>\n", |
| 65 | + " <td>44.7</td>\n", |
| 66 | + " </tr>\n", |
| 67 | + " <tr>\n", |
| 68 | + " <th>1</th>\n", |
| 69 | + " <td>2</td>\n", |
| 70 | + " <td>Mexico</td>\n", |
| 71 | + " <td>Americas</td>\n", |
| 72 | + " <td>76.4</td>\n", |
| 73 | + " <td>7.3</td>\n", |
| 74 | + " <td>19%</td>\n", |
| 75 | + " <td>2.9</td>\n", |
| 76 | + " <td>40.7</td>\n", |
| 77 | + " </tr>\n", |
| 78 | + " <tr>\n", |
| 79 | + " <th>2</th>\n", |
| 80 | + " <td>3</td>\n", |
| 81 | + " <td>Colombia</td>\n", |
| 82 | + " <td>Americas</td>\n", |
| 83 | + " <td>73.7</td>\n", |
| 84 | + " <td>6.4</td>\n", |
| 85 | + " <td>24%</td>\n", |
| 86 | + " <td>1.9</td>\n", |
| 87 | + " <td>40.7</td>\n", |
| 88 | + " </tr>\n", |
| 89 | + " <tr>\n", |
| 90 | + " <th>3</th>\n", |
| 91 | + " <td>4</td>\n", |
| 92 | + " <td>Vanuatu</td>\n", |
| 93 | + " <td>Asia Pacific</td>\n", |
| 94 | + " <td>71.3</td>\n", |
| 95 | + " <td>6.5</td>\n", |
| 96 | + " <td>22%</td>\n", |
| 97 | + " <td>1.9</td>\n", |
| 98 | + " <td>40.6</td>\n", |
| 99 | + " </tr>\n", |
| 100 | + " <tr>\n", |
| 101 | + " <th>4</th>\n", |
| 102 | + " <td>5</td>\n", |
| 103 | + " <td>Vietnam</td>\n", |
| 104 | + " <td>Asia Pacific</td>\n", |
| 105 | + " <td>75.5</td>\n", |
| 106 | + " <td>5.5</td>\n", |
| 107 | + " <td>19%</td>\n", |
| 108 | + " <td>1.7</td>\n", |
| 109 | + " <td>40.3</td>\n", |
| 110 | + " </tr>\n", |
| 111 | + " </tbody>\n", |
| 112 | + "</table>\n", |
| 113 | + "</div>" |
| 114 | + ], |
| 115 | + "text/plain": [ |
| 116 | + " HPI Rank Country Region Life Expectancy (years) \\\n", |
| 117 | + "0 1 Costa Rica Americas 79.1 \n", |
| 118 | + "1 2 Mexico Americas 76.4 \n", |
| 119 | + "2 3 Colombia Americas 73.7 \n", |
| 120 | + "3 4 Vanuatu Asia Pacific 71.3 \n", |
| 121 | + "4 5 Vietnam Asia Pacific 75.5 \n", |
| 122 | + "\n", |
| 123 | + " Wellbeing (0-10) Inequality of outcomes Ecological Footprint (gha/capita) \\\n", |
| 124 | + "0 7.3 15% 2.8 \n", |
| 125 | + "1 7.3 19% 2.9 \n", |
| 126 | + "2 6.4 24% 1.9 \n", |
| 127 | + "3 6.5 22% 1.9 \n", |
| 128 | + "4 5.5 19% 1.7 \n", |
| 129 | + "\n", |
| 130 | + " Happy Planet Index \n", |
| 131 | + "0 44.7 \n", |
| 132 | + "1 40.7 \n", |
| 133 | + "2 40.7 \n", |
| 134 | + "3 40.6 \n", |
| 135 | + "4 40.3 " |
| 136 | + ] |
| 137 | + }, |
| 138 | + "execution_count": 2, |
| 139 | + "metadata": {}, |
| 140 | + "output_type": "execute_result" |
| 141 | + } |
| 142 | + ], |
| 143 | + "source": [ |
| 144 | + "#Download the data from Github repo \n", |
| 145 | + "hpi_url = \"https://raw.githubusercontent.com/TrainingByPackt/Interactive-Data-Visualization-with-Python/master/datasets/hpi_data_countries.tsv\"\n", |
| 146 | + "\n", |
| 147 | + "# Once downloaded, read it into a dataframe using pandas\n", |
| 148 | + "hpi_df = pd.read_csv(hpi_url, sep='\\t')\n", |
| 149 | + "hpi_df.head()\n" |
| 150 | + ] |
| 151 | + }, |
| 152 | + { |
| 153 | + "cell_type": "code", |
| 154 | + "execution_count": null, |
| 155 | + "metadata": {}, |
| 156 | + "outputs": [], |
| 157 | + "source": [] |
| 158 | + } |
| 159 | + ], |
| 160 | + "metadata": { |
| 161 | + "kernelspec": { |
| 162 | + "display_name": "Python 3", |
| 163 | + "language": "python", |
| 164 | + "name": "python3" |
| 165 | + }, |
| 166 | + "language_info": { |
| 167 | + "codemirror_mode": { |
| 168 | + "name": "ipython", |
| 169 | + "version": 3 |
| 170 | + }, |
| 171 | + "file_extension": ".py", |
| 172 | + "mimetype": "text/x-python", |
| 173 | + "name": "python", |
| 174 | + "nbconvert_exporter": "python", |
| 175 | + "pygments_lexer": "ipython3", |
| 176 | + "version": "3.7.3" |
| 177 | + } |
| 178 | + }, |
| 179 | + "nbformat": 4, |
| 180 | + "nbformat_minor": 2 |
| 181 | +} |
0 commit comments