{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPython 3.5.5\n",
      "IPython 6.2.1\n",
      "\n",
      "numpy 1.14.1\n",
      "scipy 1.0.0\n",
      "sklearn 0.19.1\n",
      "pandas 0.22.0\n",
      "matplotlib 2.2.2\n"
     ]
    }
   ],
   "source": [
    "%load_ext watermark\n",
    "%watermark -v -p numpy,scipy,sklearn,pandas,matplotlib"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**1장 – 한 눈에 보는 머신러닝**\n",
    "\n",
    "_이 노트북은 1장의 그림을 생성하기 위한 것입니다._"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 설정"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "파이썬 2와 3을 모두 지원합니다. 공통 모듈을 임포트하고 맷플롯립 그림이 노트북 안에 포함되도록 설정하고 생성한 그림을 저장하기 위한 함수를 준비합니다:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "slideshow": {
     "slide_type": "-"
    }
   },
   "outputs": [],
   "source": [
    "# 파이썬 2와 파이썬 3 지원\n",
    "from __future__ import division, print_function, unicode_literals\n",
    "\n",
    "# 공통\n",
    "import numpy as np\n",
    "import os\n",
    "\n",
    "# 일관된 출력을 위해 유사난수 초기화\n",
    "np.random.seed(42)\n",
    "\n",
    "# 맷플롯립 설정\n",
    "%matplotlib inline\n",
    "import matplotlib\n",
    "import matplotlib.pyplot as plt\n",
    "plt.rcParams['axes.labelsize'] = 14\n",
    "plt.rcParams['xtick.labelsize'] = 12\n",
    "plt.rcParams['ytick.labelsize'] = 12\n",
    "\n",
    "# 한글출력\n",
    "matplotlib.rc('font', family='NanumBarunGothic')\n",
    "plt.rcParams['axes.unicode_minus'] = False\n",
    "\n",
    "# 그림을 저장할 폴드\n",
    "PROJECT_ROOT_DIR = \".\"\n",
    "CHAPTER_ID = \"fundamentals\"\n",
    "\n",
    "def save_fig(fig_id, tight_layout=True):\n",
    "    path = os.path.join(PROJECT_ROOT_DIR, \"images\", CHAPTER_ID, fig_id + \".png\")\n",
    "    if tight_layout:\n",
    "        plt.tight_layout()\n",
    "    plt.savefig(path, format='png', dpi=300)\n",
    "\n",
    "# SciPy 이슈 #5998에 해당하는 경고를 무시합니다(https://github.com/scipy/scipy/issues/5998).\n",
    "import warnings\n",
    "warnings.filterwarnings(action=\"ignore\", module=\"scipy\", message=\"^internal gelsd\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 예제 1-1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "이 함수는 OECD의 삶의 만족도(life satisfaction) 데이터와 IMF의 1인당 GDP(GDP per capita) 데이터를 합칩니다.\n",
    "이는 번거로운 작업이고 머신러닝과는 관계가 없기 때문에 책 안에 포함시키지 않았습니다."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "def prepare_country_stats(oecd_bli, gdp_per_capita):\n",
    "    oecd_bli = oecd_bli[oecd_bli[\"INEQUALITY\"]==\"TOT\"]\n",
    "    oecd_bli = oecd_bli.pivot(index=\"Country\", columns=\"Indicator\", values=\"Value\")\n",
    "    gdp_per_capita.rename(columns={\"2015\": \"GDP per capita\"}, inplace=True)\n",
    "    gdp_per_capita.set_index(\"Country\", inplace=True)\n",
    "    full_country_stats = pd.merge(left=oecd_bli, right=gdp_per_capita,\n",
    "                                  left_index=True, right_index=True)\n",
    "    full_country_stats.sort_values(by=\"GDP per capita\", inplace=True)\n",
    "    remove_indices = [0, 1, 6, 8, 33, 34, 35]\n",
    "    keep_indices = list(set(range(36)) - set(remove_indices))\n",
    "    return full_country_stats[[\"GDP per capita\", 'Life satisfaction']].iloc[keep_indices]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "책에 있는 코드는 데이터 파일이 현재 디렉토리에 있다고 가정합니다. 여기에서는 datasets/lifesat 안에서 파일을 읽어 들입니다."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "datapath = os.path.join(\"datasets\", \"lifesat\", \"\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 9764 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[5.96242338]]\n"
     ]
    }
   ],
   "source": [
    "# 샘플 코드\n",
    "import matplotlib\n",
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "import sklearn.linear_model\n",
    "\n",
    "# 데이터 적재\n",
    "oecd_bli = pd.read_csv(datapath + \"oecd_bli_2015.csv\", thousands=',')\n",
    "gdp_per_capita = pd.read_csv(datapath + \"gdp_per_capita.csv\",thousands=',',delimiter='\\t',\n",
    "                             encoding='latin1', na_values=\"n/a\")\n",
    "\n",
    "# 데이터 준비\n",
    "country_stats = prepare_country_stats(oecd_bli, gdp_per_capita)\n",
    "X = np.c_[country_stats[\"GDP per capita\"]]\n",
    "y = np.c_[country_stats[\"Life satisfaction\"]]\n",
    "\n",
    "# 데이터 시각화\n",
    "ax = country_stats.plot(kind='scatter', x=\"GDP per capita\", y='Life satisfaction')\n",
    "ax.set(xlabel=\"삶의 만족도\", ylabel=\"1인당 GDP\")\n",
    "plt.show()\n",
    "\n",
    "# 선형 모델 선택\n",
    "model = sklearn.linear_model.LinearRegression()\n",
    "\n",
    "# 모델 훈련\n",
    "model.fit(X, y)\n",
    "\n",
    "# 키프로스에 대한 예측\n",
    "X_new = [[22587]]  # 키프로스 1인당 GDP\n",
    "print(model.predict(X_new)) # 결과 [[ 5.96242338]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[5.76666667]]\n"
     ]
    }
   ],
   "source": [
    "# 선형 회귀 모델을 k-최근접 이웃 회귀 모델로 교체할 경우\n",
    "knn = sklearn.neighbors.KNeighborsRegressor(n_neighbors=3)\n",
    "\n",
    "# 모델 훈련\n",
    "knn.fit(X, y)\n",
    "\n",
    "# 키프로스에 대한 예측\n",
    "print(knn.predict(X_new)) # 결과 [[ 5.76666667]]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 알림: 이후의 코드는 무시해도 좋습니다. 이 코드는 1장에 있는 그림을 생성하기 위한 것입니다."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 삶의 만족도 데이터 적재와 준비"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "필요하면 OECE 웹사이트에서 새 데이터를 받을 수 있습니다. http://stats.oecd.org/index.aspx?DataSetCode=BLI 에서 CSV 파일을 다운받아 `datasets/lifesat/`에 저장합니다."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>Indicator</th>\n",
       "      <th>Air pollution</th>\n",
       "      <th>Assault rate</th>\n",
       "      <th>Consultation on rule-making</th>\n",
       "      <th>Dwellings without basic facilities</th>\n",
       "      <th>Educational attainment</th>\n",
       "      <th>Employees working very long hours</th>\n",
       "      <th>Employment rate</th>\n",
       "      <th>Homicide rate</th>\n",
       "      <th>Household net adjusted disposable income</th>\n",
       "      <th>Household net financial wealth</th>\n",
       "      <th>...</th>\n",
       "      <th>Long-term unemployment rate</th>\n",
       "      <th>Personal earnings</th>\n",
       "      <th>Quality of support network</th>\n",
       "      <th>Rooms per person</th>\n",
       "      <th>Self-reported health</th>\n",
       "      <th>Student skills</th>\n",
       "      <th>Time devoted to leisure and personal care</th>\n",
       "      <th>Voter turnout</th>\n",
       "      <th>Water quality</th>\n",
       "      <th>Years in education</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Country</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Australia</th>\n",
       "      <td>13.0</td>\n",
       "      <td>2.1</td>\n",
       "      <td>10.5</td>\n",
       "      <td>1.1</td>\n",
       "      <td>76.0</td>\n",
       "      <td>14.02</td>\n",
       "      <td>72.0</td>\n",
       "      <td>0.8</td>\n",
       "      <td>31588.0</td>\n",
       "      <td>47657.0</td>\n",
       "      <td>...</td>\n",
       "      <td>1.08</td>\n",
       "      <td>50449.0</td>\n",
       "      <td>92.0</td>\n",
       "      <td>2.3</td>\n",
       "      <td>85.0</td>\n",
       "      <td>512.0</td>\n",
       "      <td>14.41</td>\n",
       "      <td>93.0</td>\n",
       "      <td>91.0</td>\n",
       "      <td>19.4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Austria</th>\n",
       "      <td>27.0</td>\n",
       "      <td>3.4</td>\n",
       "      <td>7.1</td>\n",
       "      <td>1.0</td>\n",
       "      <td>83.0</td>\n",
       "      <td>7.61</td>\n",
       "      <td>72.0</td>\n",
       "      <td>0.4</td>\n",
       "      <td>31173.0</td>\n",
       "      <td>49887.0</td>\n",
       "      <td>...</td>\n",
       "      <td>1.19</td>\n",
       "      <td>45199.0</td>\n",
       "      <td>89.0</td>\n",
       "      <td>1.6</td>\n",
       "      <td>69.0</td>\n",
       "      <td>500.0</td>\n",
       "      <td>14.46</td>\n",
       "      <td>75.0</td>\n",
       "      <td>94.0</td>\n",
       "      <td>17.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>2 rows × 24 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "Indicator  Air pollution  Assault rate  Consultation on rule-making  \\\n",
       "Country                                                               \n",
       "Australia           13.0           2.1                         10.5   \n",
       "Austria             27.0           3.4                          7.1   \n",
       "\n",
       "Indicator  Dwellings without basic facilities  Educational attainment  \\\n",
       "Country                                                                 \n",
       "Australia                                 1.1                    76.0   \n",
       "Austria                                   1.0                    83.0   \n",
       "\n",
       "Indicator  Employees working very long hours  Employment rate  Homicide rate  \\\n",
       "Country                                                                        \n",
       "Australia                              14.02             72.0            0.8   \n",
       "Austria                                 7.61             72.0            0.4   \n",
       "\n",
       "Indicator  Household net adjusted disposable income  \\\n",
       "Country                                               \n",
       "Australia                                   31588.0   \n",
       "Austria                                     31173.0   \n",
       "\n",
       "Indicator  Household net financial wealth         ...          \\\n",
       "Country                                           ...           \n",
       "Australia                         47657.0         ...           \n",
       "Austria                           49887.0         ...           \n",
       "\n",
       "Indicator  Long-term unemployment rate  Personal earnings  \\\n",
       "Country                                                     \n",
       "Australia                         1.08            50449.0   \n",
       "Austria                           1.19            45199.0   \n",
       "\n",
       "Indicator  Quality of support network  Rooms per person  Self-reported health  \\\n",
       "Country                                                                         \n",
       "Australia                        92.0               2.3                  85.0   \n",
       "Austria                          89.0               1.6                  69.0   \n",
       "\n",
       "Indicator  Student skills  Time devoted to leisure and personal care  \\\n",
       "Country                                                                \n",
       "Australia           512.0                                      14.41   \n",
       "Austria             500.0                                      14.46   \n",
       "\n",
       "Indicator  Voter turnout  Water quality  Years in education  \n",
       "Country                                                      \n",
       "Australia           93.0           91.0                19.4  \n",
       "Austria             75.0           94.0                17.0  \n",
       "\n",
       "[2 rows x 24 columns]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "oecd_bli = pd.read_csv(datapath + \"oecd_bli_2015.csv\", thousands=',')\n",
    "oecd_bli = oecd_bli[oecd_bli[\"INEQUALITY\"]==\"TOT\"]\n",
    "oecd_bli = oecd_bli.pivot(index=\"Country\", columns=\"Indicator\", values=\"Value\")\n",
    "oecd_bli.head(2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Country\n",
       "Australia    7.3\n",
       "Austria      6.9\n",
       "Belgium      6.9\n",
       "Brazil       7.0\n",
       "Canada       7.3\n",
       "Name: Life satisfaction, dtype: float64"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "oecd_bli[\"Life satisfaction\"].head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 1인당 GDP 데이터 적재와 준비"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "위와 마찬가지로 필요하면 1인당 GDP 데이터를 새로 받을 수 있습니다. http://goo.gl/j1MSKe (=> imf.org)에서 다운받아 `datasets/lifesat/`에 저장하면 됩니다."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Subject Descriptor</th>\n",
       "      <th>Units</th>\n",
       "      <th>Scale</th>\n",
       "      <th>Country/Series-specific Notes</th>\n",
       "      <th>GDP per capita</th>\n",
       "      <th>Estimates Start After</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Country</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Afghanistan</th>\n",
       "      <td>Gross domestic product per capita, current prices</td>\n",
       "      <td>U.S. dollars</td>\n",
       "      <td>Units</td>\n",
       "      <td>See notes for:  Gross domestic product, curren...</td>\n",
       "      <td>599.994</td>\n",
       "      <td>2013.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Albania</th>\n",
       "      <td>Gross domestic product per capita, current prices</td>\n",
       "      <td>U.S. dollars</td>\n",
       "      <td>Units</td>\n",
       "      <td>See notes for:  Gross domestic product, curren...</td>\n",
       "      <td>3995.383</td>\n",
       "      <td>2010.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                            Subject Descriptor         Units  \\\n",
       "Country                                                                        \n",
       "Afghanistan  Gross domestic product per capita, current prices  U.S. dollars   \n",
       "Albania      Gross domestic product per capita, current prices  U.S. dollars   \n",
       "\n",
       "             Scale                      Country/Series-specific Notes  \\\n",
       "Country                                                                 \n",
       "Afghanistan  Units  See notes for:  Gross domestic product, curren...   \n",
       "Albania      Units  See notes for:  Gross domestic product, curren...   \n",
       "\n",
       "             GDP per capita  Estimates Start After  \n",
       "Country                                             \n",
       "Afghanistan         599.994                 2013.0  \n",
       "Albania            3995.383                 2010.0  "
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "gdp_per_capita = pd.read_csv(datapath+\"gdp_per_capita.csv\", thousands=',', delimiter='\\t',\n",
    "                             encoding='latin1', na_values=\"n/a\")\n",
    "gdp_per_capita.rename(columns={\"2015\": \"GDP per capita\"}, inplace=True)\n",
    "gdp_per_capita.set_index(\"Country\", inplace=True)\n",
    "gdp_per_capita.head(2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Air pollution</th>\n",
       "      <th>Assault rate</th>\n",
       "      <th>Consultation on rule-making</th>\n",
       "      <th>Dwellings without basic facilities</th>\n",
       "      <th>Educational attainment</th>\n",
       "      <th>Employees working very long hours</th>\n",
       "      <th>Employment rate</th>\n",
       "      <th>Homicide rate</th>\n",
       "      <th>Household net adjusted disposable income</th>\n",
       "      <th>Household net financial wealth</th>\n",
       "      <th>...</th>\n",
       "      <th>Time devoted to leisure and personal care</th>\n",
       "      <th>Voter turnout</th>\n",
       "      <th>Water quality</th>\n",
       "      <th>Years in education</th>\n",
       "      <th>Subject Descriptor</th>\n",
       "      <th>Units</th>\n",
       "      <th>Scale</th>\n",
       "      <th>Country/Series-specific Notes</th>\n",
       "      <th>GDP per capita</th>\n",
       "      <th>Estimates Start After</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Country</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Brazil</th>\n",
       "      <td>18.0</td>\n",
       "      <td>7.9</td>\n",
       "      <td>4.0</td>\n",
       "      <td>6.7</td>\n",
       "      <td>45.0</td>\n",
       "      <td>10.41</td>\n",
       "      <td>67.0</td>\n",
       "      <td>25.5</td>\n",
       "      <td>11664.0</td>\n",
       "      <td>6844.0</td>\n",
       "      <td>...</td>\n",
       "      <td>14.97</td>\n",
       "      <td>79.0</td>\n",
       "      <td>72.0</td>\n",
       "      <td>16.3</td>\n",
       "      <td>Gross domestic product per capita, current prices</td>\n",
       "      <td>U.S. dollars</td>\n",
       "      <td>Units</td>\n",
       "      <td>See notes for:  Gross domestic product, curren...</td>\n",
       "      <td>8669.998</td>\n",
       "      <td>2014.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Mexico</th>\n",
       "      <td>30.0</td>\n",
       "      <td>12.8</td>\n",
       "      <td>9.0</td>\n",
       "      <td>4.2</td>\n",
       "      <td>37.0</td>\n",
       "      <td>28.83</td>\n",
       "      <td>61.0</td>\n",
       "      <td>23.4</td>\n",
       "      <td>13085.0</td>\n",
       "      <td>9056.0</td>\n",
       "      <td>...</td>\n",
       "      <td>13.89</td>\n",
       "      <td>63.0</td>\n",
       "      <td>67.0</td>\n",
       "      <td>14.4</td>\n",
       "      <td>Gross domestic product per capita, current prices</td>\n",
       "      <td>U.S. dollars</td>\n",
       "      <td>Units</td>\n",
       "      <td>See notes for:  Gross domestic product, curren...</td>\n",
       "      <td>9009.280</td>\n",
       "      <td>2015.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Russia</th>\n",
       "      <td>15.0</td>\n",
       "      <td>3.8</td>\n",
       "      <td>2.5</td>\n",
       "      <td>15.1</td>\n",
       "      <td>94.0</td>\n",
       "      <td>0.16</td>\n",
       "      <td>69.0</td>\n",
       "      <td>12.8</td>\n",
       "      <td>19292.0</td>\n",
       "      <td>3412.0</td>\n",
       "      <td>...</td>\n",
       "      <td>14.97</td>\n",
       "      <td>65.0</td>\n",
       "      <td>56.0</td>\n",
       "      <td>16.0</td>\n",
       "      <td>Gross domestic product per capita, current prices</td>\n",
       "      <td>U.S. dollars</td>\n",
       "      <td>Units</td>\n",
       "      <td>See notes for:  Gross domestic product, curren...</td>\n",
       "      <td>9054.914</td>\n",
       "      <td>2015.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Turkey</th>\n",
       "      <td>35.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>5.5</td>\n",
       "      <td>12.7</td>\n",
       "      <td>34.0</td>\n",
       "      <td>40.86</td>\n",
       "      <td>50.0</td>\n",
       "      <td>1.2</td>\n",
       "      <td>14095.0</td>\n",
       "      <td>3251.0</td>\n",
       "      <td>...</td>\n",
       "      <td>13.42</td>\n",
       "      <td>88.0</td>\n",
       "      <td>62.0</td>\n",
       "      <td>16.4</td>\n",
       "      <td>Gross domestic product per capita, current prices</td>\n",
       "      <td>U.S. dollars</td>\n",
       "      <td>Units</td>\n",
       "      <td>See notes for:  Gross domestic product, curren...</td>\n",
       "      <td>9437.372</td>\n",
       "      <td>2013.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Hungary</th>\n",
       "      <td>15.0</td>\n",
       "      <td>3.6</td>\n",
       "      <td>7.9</td>\n",
       "      <td>4.8</td>\n",
       "      <td>82.0</td>\n",
       "      <td>3.19</td>\n",
       "      <td>58.0</td>\n",
       "      <td>1.3</td>\n",
       "      <td>15442.0</td>\n",
       "      <td>13277.0</td>\n",
       "      <td>...</td>\n",
       "      <td>15.04</td>\n",
       "      <td>62.0</td>\n",
       "      <td>77.0</td>\n",
       "      <td>17.6</td>\n",
       "      <td>Gross domestic product per capita, current prices</td>\n",
       "      <td>U.S. dollars</td>\n",
       "      <td>Units</td>\n",
       "      <td>See notes for:  Gross domestic product, curren...</td>\n",
       "      <td>12239.894</td>\n",
       "      <td>2015.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Poland</th>\n",
       "      <td>33.0</td>\n",
       "      <td>1.4</td>\n",
       "      <td>10.8</td>\n",
       "      <td>3.2</td>\n",
       "      <td>90.0</td>\n",
       "      <td>7.41</td>\n",
       "      <td>60.0</td>\n",
       "      <td>0.9</td>\n",
       "      <td>17852.0</td>\n",
       "      <td>10919.0</td>\n",
       "      <td>...</td>\n",
       "      <td>14.20</td>\n",
       "      <td>55.0</td>\n",
       "      <td>79.0</td>\n",
       "      <td>18.4</td>\n",
       "      <td>Gross domestic product per capita, current prices</td>\n",
       "      <td>U.S. dollars</td>\n",
       "      <td>Units</td>\n",
       "      <td>See notes for:  Gross domestic product, curren...</td>\n",
       "      <td>12495.334</td>\n",
       "      <td>2014.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Chile</th>\n",
       "      <td>46.0</td>\n",
       "      <td>6.9</td>\n",
       "      <td>2.0</td>\n",
       "      <td>9.4</td>\n",
       "      <td>57.0</td>\n",
       "      <td>15.42</td>\n",
       "      <td>62.0</td>\n",
       "      <td>4.4</td>\n",
       "      <td>14533.0</td>\n",
       "      <td>17733.0</td>\n",
       "      <td>...</td>\n",
       "      <td>14.41</td>\n",
       "      <td>49.0</td>\n",
       "      <td>73.0</td>\n",
       "      <td>16.5</td>\n",
       "      <td>Gross domestic product per capita, current prices</td>\n",
       "      <td>U.S. dollars</td>\n",
       "      <td>Units</td>\n",
       "      <td>See notes for:  Gross domestic product, curren...</td>\n",
       "      <td>13340.905</td>\n",
       "      <td>2014.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Slovak Republic</th>\n",
       "      <td>13.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>6.6</td>\n",
       "      <td>0.6</td>\n",
       "      <td>92.0</td>\n",
       "      <td>7.02</td>\n",
       "      <td>60.0</td>\n",
       "      <td>1.2</td>\n",
       "      <td>17503.0</td>\n",
       "      <td>8663.0</td>\n",
       "      <td>...</td>\n",
       "      <td>14.99</td>\n",
       "      <td>59.0</td>\n",
       "      <td>81.0</td>\n",
       "      <td>16.3</td>\n",
       "      <td>Gross domestic product per capita, current prices</td>\n",
       "      <td>U.S. dollars</td>\n",
       "      <td>Units</td>\n",
       "      <td>See notes for:  Gross domestic product, curren...</td>\n",
       "      <td>15991.736</td>\n",
       "      <td>2015.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Czech Republic</th>\n",
       "      <td>16.0</td>\n",
       "      <td>2.8</td>\n",
       "      <td>6.8</td>\n",
       "      <td>0.9</td>\n",
       "      <td>92.0</td>\n",
       "      <td>6.98</td>\n",
       "      <td>68.0</td>\n",
       "      <td>0.8</td>\n",
       "      <td>18404.0</td>\n",
       "      <td>17299.0</td>\n",
       "      <td>...</td>\n",
       "      <td>14.98</td>\n",
       "      <td>59.0</td>\n",
       "      <td>85.0</td>\n",
       "      <td>18.1</td>\n",
       "      <td>Gross domestic product per capita, current prices</td>\n",
       "      <td>U.S. dollars</td>\n",
       "      <td>Units</td>\n",
       "      <td>See notes for:  Gross domestic product, curren...</td>\n",
       "      <td>17256.918</td>\n",
       "      <td>2015.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Estonia</th>\n",
       "      <td>9.0</td>\n",
       "      <td>5.5</td>\n",
       "      <td>3.3</td>\n",
       "      <td>8.1</td>\n",
       "      <td>90.0</td>\n",
       "      <td>3.30</td>\n",
       "      <td>68.0</td>\n",
       "      <td>4.8</td>\n",
       "      <td>15167.0</td>\n",
       "      <td>7680.0</td>\n",
       "      <td>...</td>\n",
       "      <td>14.90</td>\n",
       "      <td>64.0</td>\n",
       "      <td>79.0</td>\n",
       "      <td>17.5</td>\n",
       "      <td>Gross domestic product per capita, current prices</td>\n",
       "      <td>U.S. dollars</td>\n",
       "      <td>Units</td>\n",
       "      <td>See notes for:  Gross domestic product, curren...</td>\n",
       "      <td>17288.083</td>\n",
       "      <td>2014.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Greece</th>\n",
       "      <td>27.0</td>\n",
       "      <td>3.7</td>\n",
       "      <td>6.5</td>\n",
       "      <td>0.7</td>\n",
       "      <td>68.0</td>\n",
       "      <td>6.16</td>\n",
       "      <td>49.0</td>\n",
       "      <td>1.6</td>\n",
       "      <td>18575.0</td>\n",
       "      <td>14579.0</td>\n",
       "      <td>...</td>\n",
       "      <td>14.91</td>\n",
       "      <td>64.0</td>\n",
       "      <td>69.0</td>\n",
       "      <td>18.6</td>\n",
       "      <td>Gross domestic product per capita, current prices</td>\n",
       "      <td>U.S. dollars</td>\n",
       "      <td>Units</td>\n",
       "      <td>See notes for:  Gross domestic product, curren...</td>\n",
       "      <td>18064.288</td>\n",
       "      <td>2014.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Portugal</th>\n",
       "      <td>18.0</td>\n",
       "      <td>5.7</td>\n",
       "      <td>6.5</td>\n",
       "      <td>0.9</td>\n",
       "      <td>38.0</td>\n",
       "      <td>9.62</td>\n",
       "      <td>61.0</td>\n",
       "      <td>1.1</td>\n",
       "      <td>20086.0</td>\n",
       "      <td>31245.0</td>\n",
       "      <td>...</td>\n",
       "      <td>14.95</td>\n",
       "      <td>58.0</td>\n",
       "      <td>86.0</td>\n",
       "      <td>17.6</td>\n",
       "      <td>Gross domestic product per capita, current prices</td>\n",
       "      <td>U.S. dollars</td>\n",
       "      <td>Units</td>\n",
       "      <td>See notes for:  Gross domestic product, curren...</td>\n",
       "      <td>19121.592</td>\n",
       "      <td>2014.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Slovenia</th>\n",
       "      <td>26.0</td>\n",
       "      <td>3.9</td>\n",
       "      <td>10.3</td>\n",
       "      <td>0.5</td>\n",
       "      <td>85.0</td>\n",
       "      <td>5.63</td>\n",
       "      <td>63.0</td>\n",
       "      <td>0.4</td>\n",
       "      <td>19326.0</td>\n",
       "      <td>18465.0</td>\n",
       "      <td>...</td>\n",
       "      <td>14.62</td>\n",
       "      <td>52.0</td>\n",
       "      <td>88.0</td>\n",
       "      <td>18.4</td>\n",
       "      <td>Gross domestic product per capita, current prices</td>\n",
       "      <td>U.S. dollars</td>\n",
       "      <td>Units</td>\n",
       "      <td>See notes for:  Gross domestic product, curren...</td>\n",
       "      <td>20732.482</td>\n",
       "      <td>2015.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Spain</th>\n",
       "      <td>24.0</td>\n",
       "      <td>4.2</td>\n",
       "      <td>7.3</td>\n",
       "      <td>0.1</td>\n",
       "      <td>55.0</td>\n",
       "      <td>5.89</td>\n",
       "      <td>56.0</td>\n",
       "      <td>0.6</td>\n",
       "      <td>22477.0</td>\n",
       "      <td>24774.0</td>\n",
       "      <td>...</td>\n",
       "      <td>16.06</td>\n",
       "      <td>69.0</td>\n",
       "      <td>71.0</td>\n",
       "      <td>17.6</td>\n",
       "      <td>Gross domestic product per capita, current prices</td>\n",
       "      <td>U.S. dollars</td>\n",
       "      <td>Units</td>\n",
       "      <td>See notes for:  Gross domestic product, curren...</td>\n",
       "      <td>25864.721</td>\n",
       "      <td>2014.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Korea</th>\n",
       "      <td>30.0</td>\n",
       "      <td>2.1</td>\n",
       "      <td>10.4</td>\n",
       "      <td>4.2</td>\n",
       "      <td>82.0</td>\n",
       "      <td>18.72</td>\n",
       "      <td>64.0</td>\n",
       "      <td>1.1</td>\n",
       "      <td>19510.0</td>\n",
       "      <td>29091.0</td>\n",
       "      <td>...</td>\n",
       "      <td>14.63</td>\n",
       "      <td>76.0</td>\n",
       "      <td>78.0</td>\n",
       "      <td>17.5</td>\n",
       "      <td>Gross domestic product per capita, current prices</td>\n",
       "      <td>U.S. dollars</td>\n",
       "      <td>Units</td>\n",
       "      <td>See notes for:  Gross domestic product, curren...</td>\n",
       "      <td>27195.197</td>\n",
       "      <td>2014.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Italy</th>\n",
       "      <td>21.0</td>\n",
       "      <td>4.7</td>\n",
       "      <td>5.0</td>\n",
       "      <td>1.1</td>\n",
       "      <td>57.0</td>\n",
       "      <td>3.66</td>\n",
       "      <td>56.0</td>\n",
       "      <td>0.7</td>\n",
       "      <td>25166.0</td>\n",
       "      <td>54987.0</td>\n",
       "      <td>...</td>\n",
       "      <td>14.98</td>\n",
       "      <td>75.0</td>\n",
       "      <td>71.0</td>\n",
       "      <td>16.8</td>\n",
       "      <td>Gross domestic product per capita, current prices</td>\n",
       "      <td>U.S. dollars</td>\n",
       "      <td>Units</td>\n",
       "      <td>See notes for:  Gross domestic product, curren...</td>\n",
       "      <td>29866.581</td>\n",
       "      <td>2015.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Japan</th>\n",
       "      <td>24.0</td>\n",
       "      <td>1.4</td>\n",
       "      <td>7.3</td>\n",
       "      <td>6.4</td>\n",
       "      <td>94.0</td>\n",
       "      <td>22.26</td>\n",
       "      <td>72.0</td>\n",
       "      <td>0.3</td>\n",
       "      <td>26111.0</td>\n",
       "      <td>86764.0</td>\n",
       "      <td>...</td>\n",
       "      <td>14.93</td>\n",
       "      <td>53.0</td>\n",
       "      <td>85.0</td>\n",
       "      <td>16.3</td>\n",
       "      <td>Gross domestic product per capita, current prices</td>\n",
       "      <td>U.S. dollars</td>\n",
       "      <td>Units</td>\n",
       "      <td>See notes for:  Gross domestic product, curren...</td>\n",
       "      <td>32485.545</td>\n",
       "      <td>2015.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Israel</th>\n",
       "      <td>21.0</td>\n",
       "      <td>6.4</td>\n",
       "      <td>2.5</td>\n",
       "      <td>3.7</td>\n",
       "      <td>85.0</td>\n",
       "      <td>16.03</td>\n",
       "      <td>67.0</td>\n",
       "      <td>2.3</td>\n",
       "      <td>22104.0</td>\n",
       "      <td>52933.0</td>\n",
       "      <td>...</td>\n",
       "      <td>14.48</td>\n",
       "      <td>68.0</td>\n",
       "      <td>68.0</td>\n",
       "      <td>15.8</td>\n",
       "      <td>Gross domestic product per capita, current prices</td>\n",
       "      <td>U.S. dollars</td>\n",
       "      <td>Units</td>\n",
       "      <td>See notes for:  Gross domestic product, curren...</td>\n",
       "      <td>35343.336</td>\n",
       "      <td>2015.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>New Zealand</th>\n",
       "      <td>11.0</td>\n",
       "      <td>2.2</td>\n",
       "      <td>10.3</td>\n",
       "      <td>0.2</td>\n",
       "      <td>74.0</td>\n",
       "      <td>13.87</td>\n",
       "      <td>73.0</td>\n",
       "      <td>1.2</td>\n",
       "      <td>23815.0</td>\n",
       "      <td>28290.0</td>\n",
       "      <td>...</td>\n",
       "      <td>14.87</td>\n",
       "      <td>77.0</td>\n",
       "      <td>89.0</td>\n",
       "      <td>18.1</td>\n",
       "      <td>Gross domestic product per capita, current prices</td>\n",
       "      <td>U.S. dollars</td>\n",
       "      <td>Units</td>\n",
       "      <td>See notes for:  Gross domestic product, curren...</td>\n",
       "      <td>37044.891</td>\n",
       "      <td>2015.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>France</th>\n",
       "      <td>12.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>3.5</td>\n",
       "      <td>0.5</td>\n",
       "      <td>73.0</td>\n",
       "      <td>8.15</td>\n",
       "      <td>64.0</td>\n",
       "      <td>0.6</td>\n",
       "      <td>28799.0</td>\n",
       "      <td>48741.0</td>\n",
       "      <td>...</td>\n",
       "      <td>15.33</td>\n",
       "      <td>80.0</td>\n",
       "      <td>82.0</td>\n",
       "      <td>16.4</td>\n",
       "      <td>Gross domestic product per capita, current prices</td>\n",
       "      <td>U.S. dollars</td>\n",
       "      <td>Units</td>\n",
       "      <td>See notes for:  Gross domestic product, curren...</td>\n",
       "      <td>37675.006</td>\n",
       "      <td>2015.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Belgium</th>\n",
       "      <td>21.0</td>\n",
       "      <td>6.6</td>\n",
       "      <td>4.5</td>\n",
       "      <td>2.0</td>\n",
       "      <td>72.0</td>\n",
       "      <td>4.57</td>\n",
       "      <td>62.0</td>\n",
       "      <td>1.1</td>\n",
       "      <td>28307.0</td>\n",
       "      <td>83876.0</td>\n",
       "      <td>...</td>\n",
       "      <td>15.71</td>\n",
       "      <td>89.0</td>\n",
       "      <td>87.0</td>\n",
       "      <td>18.9</td>\n",
       "      <td>Gross domestic product per capita, current prices</td>\n",
       "      <td>U.S. dollars</td>\n",
       "      <td>Units</td>\n",
       "      <td>See notes for:  Gross domestic product, curren...</td>\n",
       "      <td>40106.632</td>\n",
       "      <td>2014.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Germany</th>\n",
       "      <td>16.0</td>\n",
       "      <td>3.6</td>\n",
       "      <td>4.5</td>\n",
       "      <td>0.1</td>\n",
       "      <td>86.0</td>\n",
       "      <td>5.25</td>\n",
       "      <td>73.0</td>\n",
       "      <td>0.5</td>\n",
       "      <td>31252.0</td>\n",
       "      <td>50394.0</td>\n",
       "      <td>...</td>\n",
       "      <td>15.31</td>\n",
       "      <td>72.0</td>\n",
       "      <td>95.0</td>\n",
       "      <td>18.2</td>\n",
       "      <td>Gross domestic product per capita, current prices</td>\n",
       "      <td>U.S. dollars</td>\n",
       "      <td>Units</td>\n",
       "      <td>See notes for:  Gross domestic product, curren...</td>\n",
       "      <td>40996.511</td>\n",
       "      <td>2014.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Finland</th>\n",
       "      <td>15.0</td>\n",
       "      <td>2.4</td>\n",
       "      <td>9.0</td>\n",
       "      <td>0.6</td>\n",
       "      <td>85.0</td>\n",
       "      <td>3.58</td>\n",
       "      <td>69.0</td>\n",
       "      <td>1.4</td>\n",
       "      <td>27927.0</td>\n",
       "      <td>18761.0</td>\n",
       "      <td>...</td>\n",
       "      <td>14.89</td>\n",
       "      <td>69.0</td>\n",
       "      <td>94.0</td>\n",
       "      <td>19.7</td>\n",
       "      <td>Gross domestic product per capita, current prices</td>\n",
       "      <td>U.S. dollars</td>\n",
       "      <td>Units</td>\n",
       "      <td>See notes for:  Gross domestic product, curren...</td>\n",
       "      <td>41973.988</td>\n",
       "      <td>2014.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Canada</th>\n",
       "      <td>15.0</td>\n",
       "      <td>1.3</td>\n",
       "      <td>10.5</td>\n",
       "      <td>0.2</td>\n",
       "      <td>89.0</td>\n",
       "      <td>3.94</td>\n",
       "      <td>72.0</td>\n",
       "      <td>1.5</td>\n",
       "      <td>29365.0</td>\n",
       "      <td>67913.0</td>\n",
       "      <td>...</td>\n",
       "      <td>14.25</td>\n",
       "      <td>61.0</td>\n",
       "      <td>91.0</td>\n",
       "      <td>17.2</td>\n",
       "      <td>Gross domestic product per capita, current prices</td>\n",
       "      <td>U.S. dollars</td>\n",
       "      <td>Units</td>\n",
       "      <td>See notes for:  Gross domestic product, curren...</td>\n",
       "      <td>43331.961</td>\n",
       "      <td>2015.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Netherlands</th>\n",
       "      <td>30.0</td>\n",
       "      <td>4.9</td>\n",
       "      <td>6.1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>73.0</td>\n",
       "      <td>0.45</td>\n",
       "      <td>74.0</td>\n",
       "      <td>0.9</td>\n",
       "      <td>27888.0</td>\n",
       "      <td>77961.0</td>\n",
       "      <td>...</td>\n",
       "      <td>15.44</td>\n",
       "      <td>75.0</td>\n",
       "      <td>92.0</td>\n",
       "      <td>18.7</td>\n",
       "      <td>Gross domestic product per capita, current prices</td>\n",
       "      <td>U.S. dollars</td>\n",
       "      <td>Units</td>\n",
       "      <td>See notes for:  Gross domestic product, curren...</td>\n",
       "      <td>43603.115</td>\n",
       "      <td>2014.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Austria</th>\n",
       "      <td>27.0</td>\n",
       "      <td>3.4</td>\n",
       "      <td>7.1</td>\n",
       "      <td>1.0</td>\n",
       "      <td>83.0</td>\n",
       "      <td>7.61</td>\n",
       "      <td>72.0</td>\n",
       "      <td>0.4</td>\n",
       "      <td>31173.0</td>\n",
       "      <td>49887.0</td>\n",
       "      <td>...</td>\n",
       "      <td>14.46</td>\n",
       "      <td>75.0</td>\n",
       "      <td>94.0</td>\n",
       "      <td>17.0</td>\n",
       "      <td>Gross domestic product per capita, current prices</td>\n",
       "      <td>U.S. dollars</td>\n",
       "      <td>Units</td>\n",
       "      <td>See notes for:  Gross domestic product, curren...</td>\n",
       "      <td>43724.031</td>\n",
       "      <td>2015.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>United Kingdom</th>\n",
       "      <td>13.0</td>\n",
       "      <td>1.9</td>\n",
       "      <td>11.5</td>\n",
       "      <td>0.2</td>\n",
       "      <td>78.0</td>\n",
       "      <td>12.70</td>\n",
       "      <td>71.0</td>\n",
       "      <td>0.3</td>\n",
       "      <td>27029.0</td>\n",
       "      <td>60778.0</td>\n",
       "      <td>...</td>\n",
       "      <td>14.83</td>\n",
       "      <td>66.0</td>\n",
       "      <td>88.0</td>\n",
       "      <td>16.4</td>\n",
       "      <td>Gross domestic product per capita, current prices</td>\n",
       "      <td>U.S. dollars</td>\n",
       "      <td>Units</td>\n",
       "      <td>See notes for:  Gross domestic product, curren...</td>\n",
       "      <td>43770.688</td>\n",
       "      <td>2015.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Sweden</th>\n",
       "      <td>10.0</td>\n",
       "      <td>5.1</td>\n",
       "      <td>10.9</td>\n",
       "      <td>0.0</td>\n",
       "      <td>88.0</td>\n",
       "      <td>1.13</td>\n",
       "      <td>74.0</td>\n",
       "      <td>0.7</td>\n",
       "      <td>29185.0</td>\n",
       "      <td>60328.0</td>\n",
       "      <td>...</td>\n",
       "      <td>15.11</td>\n",
       "      <td>86.0</td>\n",
       "      <td>95.0</td>\n",
       "      <td>19.3</td>\n",
       "      <td>Gross domestic product per capita, current prices</td>\n",
       "      <td>U.S. dollars</td>\n",
       "      <td>Units</td>\n",
       "      <td>See notes for:  Gross domestic product, curren...</td>\n",
       "      <td>49866.266</td>\n",
       "      <td>2014.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Iceland</th>\n",
       "      <td>18.0</td>\n",
       "      <td>2.7</td>\n",
       "      <td>5.1</td>\n",
       "      <td>0.4</td>\n",
       "      <td>71.0</td>\n",
       "      <td>12.25</td>\n",
       "      <td>82.0</td>\n",
       "      <td>0.3</td>\n",
       "      <td>23965.0</td>\n",
       "      <td>43045.0</td>\n",
       "      <td>...</td>\n",
       "      <td>14.61</td>\n",
       "      <td>81.0</td>\n",
       "      <td>97.0</td>\n",
       "      <td>19.8</td>\n",
       "      <td>Gross domestic product per capita, current prices</td>\n",
       "      <td>U.S. dollars</td>\n",
       "      <td>Units</td>\n",
       "      <td>See notes for:  Gross domestic product, curren...</td>\n",
       "      <td>50854.583</td>\n",
       "      <td>2014.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Australia</th>\n",
       "      <td>13.0</td>\n",
       "      <td>2.1</td>\n",
       "      <td>10.5</td>\n",
       "      <td>1.1</td>\n",
       "      <td>76.0</td>\n",
       "      <td>14.02</td>\n",
       "      <td>72.0</td>\n",
       "      <td>0.8</td>\n",
       "      <td>31588.0</td>\n",
       "      <td>47657.0</td>\n",
       "      <td>...</td>\n",
       "      <td>14.41</td>\n",
       "      <td>93.0</td>\n",
       "      <td>91.0</td>\n",
       "      <td>19.4</td>\n",
       "      <td>Gross domestic product per capita, current prices</td>\n",
       "      <td>U.S. dollars</td>\n",
       "      <td>Units</td>\n",
       "      <td>See notes for:  Gross domestic product, curren...</td>\n",
       "      <td>50961.865</td>\n",
       "      <td>2014.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Ireland</th>\n",
       "      <td>13.0</td>\n",
       "      <td>2.6</td>\n",
       "      <td>9.0</td>\n",
       "      <td>0.2</td>\n",
       "      <td>75.0</td>\n",
       "      <td>4.20</td>\n",
       "      <td>60.0</td>\n",
       "      <td>0.8</td>\n",
       "      <td>23917.0</td>\n",
       "      <td>31580.0</td>\n",
       "      <td>...</td>\n",
       "      <td>15.19</td>\n",
       "      <td>70.0</td>\n",
       "      <td>80.0</td>\n",
       "      <td>17.6</td>\n",
       "      <td>Gross domestic product per capita, current prices</td>\n",
       "      <td>U.S. dollars</td>\n",
       "      <td>Units</td>\n",
       "      <td>See notes for:  Gross domestic product, curren...</td>\n",
       "      <td>51350.744</td>\n",
       "      <td>2014.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Denmark</th>\n",
       "      <td>15.0</td>\n",
       "      <td>3.9</td>\n",
       "      <td>7.0</td>\n",
       "      <td>0.9</td>\n",
       "      <td>78.0</td>\n",
       "      <td>2.03</td>\n",
       "      <td>73.0</td>\n",
       "      <td>0.3</td>\n",
       "      <td>26491.0</td>\n",
       "      <td>44488.0</td>\n",
       "      <td>...</td>\n",
       "      <td>16.06</td>\n",
       "      <td>88.0</td>\n",
       "      <td>94.0</td>\n",
       "      <td>19.4</td>\n",
       "      <td>Gross domestic product per capita, current prices</td>\n",
       "      <td>U.S. dollars</td>\n",
       "      <td>Units</td>\n",
       "      <td>See notes for:  Gross domestic product, curren...</td>\n",
       "      <td>52114.165</td>\n",
       "      <td>2015.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>United States</th>\n",
       "      <td>18.0</td>\n",
       "      <td>1.5</td>\n",
       "      <td>8.3</td>\n",
       "      <td>0.1</td>\n",
       "      <td>89.0</td>\n",
       "      <td>11.30</td>\n",
       "      <td>67.0</td>\n",
       "      <td>5.2</td>\n",
       "      <td>41355.0</td>\n",
       "      <td>145769.0</td>\n",
       "      <td>...</td>\n",
       "      <td>14.27</td>\n",
       "      <td>68.0</td>\n",
       "      <td>85.0</td>\n",
       "      <td>17.2</td>\n",
       "      <td>Gross domestic product per capita, current prices</td>\n",
       "      <td>U.S. dollars</td>\n",
       "      <td>Units</td>\n",
       "      <td>See notes for:  Gross domestic product, curren...</td>\n",
       "      <td>55805.204</td>\n",
       "      <td>2015.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Norway</th>\n",
       "      <td>16.0</td>\n",
       "      <td>3.3</td>\n",
       "      <td>8.1</td>\n",
       "      <td>0.3</td>\n",
       "      <td>82.0</td>\n",
       "      <td>2.82</td>\n",
       "      <td>75.0</td>\n",
       "      <td>0.6</td>\n",
       "      <td>33492.0</td>\n",
       "      <td>8797.0</td>\n",
       "      <td>...</td>\n",
       "      <td>15.56</td>\n",
       "      <td>78.0</td>\n",
       "      <td>94.0</td>\n",
       "      <td>17.9</td>\n",
       "      <td>Gross domestic product per capita, current prices</td>\n",
       "      <td>U.S. dollars</td>\n",
       "      <td>Units</td>\n",
       "      <td>See notes for:  Gross domestic product, curren...</td>\n",
       "      <td>74822.106</td>\n",
       "      <td>2015.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Switzerland</th>\n",
       "      <td>20.0</td>\n",
       "      <td>4.2</td>\n",
       "      <td>8.4</td>\n",
       "      <td>0.0</td>\n",
       "      <td>86.0</td>\n",
       "      <td>6.72</td>\n",
       "      <td>80.0</td>\n",
       "      <td>0.5</td>\n",
       "      <td>33491.0</td>\n",
       "      <td>108823.0</td>\n",
       "      <td>...</td>\n",
       "      <td>14.98</td>\n",
       "      <td>49.0</td>\n",
       "      <td>96.0</td>\n",
       "      <td>17.3</td>\n",
       "      <td>Gross domestic product per capita, current prices</td>\n",
       "      <td>U.S. dollars</td>\n",
       "      <td>Units</td>\n",
       "      <td>See notes for:  Gross domestic product, curren...</td>\n",
       "      <td>80675.308</td>\n",
       "      <td>2015.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Luxembourg</th>\n",
       "      <td>12.0</td>\n",
       "      <td>4.3</td>\n",
       "      <td>6.0</td>\n",
       "      <td>0.1</td>\n",
       "      <td>78.0</td>\n",
       "      <td>3.47</td>\n",
       "      <td>66.0</td>\n",
       "      <td>0.4</td>\n",
       "      <td>38951.0</td>\n",
       "      <td>61765.0</td>\n",
       "      <td>...</td>\n",
       "      <td>15.12</td>\n",
       "      <td>91.0</td>\n",
       "      <td>86.0</td>\n",
       "      <td>15.1</td>\n",
       "      <td>Gross domestic product per capita, current prices</td>\n",
       "      <td>U.S. dollars</td>\n",
       "      <td>Units</td>\n",
       "      <td>See notes for:  Gross domestic product, curren...</td>\n",
       "      <td>101994.093</td>\n",
       "      <td>2014.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>36 rows × 30 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                 Air pollution  Assault rate  Consultation on rule-making  \\\n",
       "Country                                                                     \n",
       "Brazil                    18.0           7.9                          4.0   \n",
       "Mexico                    30.0          12.8                          9.0   \n",
       "Russia                    15.0           3.8                          2.5   \n",
       "Turkey                    35.0           5.0                          5.5   \n",
       "Hungary                   15.0           3.6                          7.9   \n",
       "Poland                    33.0           1.4                         10.8   \n",
       "Chile                     46.0           6.9                          2.0   \n",
       "Slovak Republic           13.0           3.0                          6.6   \n",
       "Czech Republic            16.0           2.8                          6.8   \n",
       "Estonia                    9.0           5.5                          3.3   \n",
       "Greece                    27.0           3.7                          6.5   \n",
       "Portugal                  18.0           5.7                          6.5   \n",
       "Slovenia                  26.0           3.9                         10.3   \n",
       "Spain                     24.0           4.2                          7.3   \n",
       "Korea                     30.0           2.1                         10.4   \n",
       "Italy                     21.0           4.7                          5.0   \n",
       "Japan                     24.0           1.4                          7.3   \n",
       "Israel                    21.0           6.4                          2.5   \n",
       "New Zealand               11.0           2.2                         10.3   \n",
       "France                    12.0           5.0                          3.5   \n",
       "Belgium                   21.0           6.6                          4.5   \n",
       "Germany                   16.0           3.6                          4.5   \n",
       "Finland                   15.0           2.4                          9.0   \n",
       "Canada                    15.0           1.3                         10.5   \n",
       "Netherlands               30.0           4.9                          6.1   \n",
       "Austria                   27.0           3.4                          7.1   \n",
       "United Kingdom            13.0           1.9                         11.5   \n",
       "Sweden                    10.0           5.1                         10.9   \n",
       "Iceland                   18.0           2.7                          5.1   \n",
       "Australia                 13.0           2.1                         10.5   \n",
       "Ireland                   13.0           2.6                          9.0   \n",
       "Denmark                   15.0           3.9                          7.0   \n",
       "United States             18.0           1.5                          8.3   \n",
       "Norway                    16.0           3.3                          8.1   \n",
       "Switzerland               20.0           4.2                          8.4   \n",
       "Luxembourg                12.0           4.3                          6.0   \n",
       "\n",
       "                 Dwellings without basic facilities  Educational attainment  \\\n",
       "Country                                                                       \n",
       "Brazil                                          6.7                    45.0   \n",
       "Mexico                                          4.2                    37.0   \n",
       "Russia                                         15.1                    94.0   \n",
       "Turkey                                         12.7                    34.0   \n",
       "Hungary                                         4.8                    82.0   \n",
       "Poland                                          3.2                    90.0   \n",
       "Chile                                           9.4                    57.0   \n",
       "Slovak Republic                                 0.6                    92.0   \n",
       "Czech Republic                                  0.9                    92.0   \n",
       "Estonia                                         8.1                    90.0   \n",
       "Greece                                          0.7                    68.0   \n",
       "Portugal                                        0.9                    38.0   \n",
       "Slovenia                                        0.5                    85.0   \n",
       "Spain                                           0.1                    55.0   \n",
       "Korea                                           4.2                    82.0   \n",
       "Italy                                           1.1                    57.0   \n",
       "Japan                                           6.4                    94.0   \n",
       "Israel                                          3.7                    85.0   \n",
       "New Zealand                                     0.2                    74.0   \n",
       "France                                          0.5                    73.0   \n",
       "Belgium                                         2.0                    72.0   \n",
       "Germany                                         0.1                    86.0   \n",
       "Finland                                         0.6                    85.0   \n",
       "Canada                                          0.2                    89.0   \n",
       "Netherlands                                     0.0                    73.0   \n",
       "Austria                                         1.0                    83.0   \n",
       "United Kingdom                                  0.2                    78.0   \n",
       "Sweden                                          0.0                    88.0   \n",
       "Iceland                                         0.4                    71.0   \n",
       "Australia                                       1.1                    76.0   \n",
       "Ireland                                         0.2                    75.0   \n",
       "Denmark                                         0.9                    78.0   \n",
       "United States                                   0.1                    89.0   \n",
       "Norway                                          0.3                    82.0   \n",
       "Switzerland                                     0.0                    86.0   \n",
       "Luxembourg                                      0.1                    78.0   \n",
       "\n",
       "                 Employees working very long hours  Employment rate  \\\n",
       "Country                                                               \n",
       "Brazil                                       10.41             67.0   \n",
       "Mexico                                       28.83             61.0   \n",
       "Russia                                        0.16             69.0   \n",
       "Turkey                                       40.86             50.0   \n",
       "Hungary                                       3.19             58.0   \n",
       "Poland                                        7.41             60.0   \n",
       "Chile                                        15.42             62.0   \n",
       "Slovak Republic                               7.02             60.0   \n",
       "Czech Republic                                6.98             68.0   \n",
       "Estonia                                       3.30             68.0   \n",
       "Greece                                        6.16             49.0   \n",
       "Portugal                                      9.62             61.0   \n",
       "Slovenia                                      5.63             63.0   \n",
       "Spain                                         5.89             56.0   \n",
       "Korea                                        18.72             64.0   \n",
       "Italy                                         3.66             56.0   \n",
       "Japan                                        22.26             72.0   \n",
       "Israel                                       16.03             67.0   \n",
       "New Zealand                                  13.87             73.0   \n",
       "France                                        8.15             64.0   \n",
       "Belgium                                       4.57             62.0   \n",
       "Germany                                       5.25             73.0   \n",
       "Finland                                       3.58             69.0   \n",
       "Canada                                        3.94             72.0   \n",
       "Netherlands                                   0.45             74.0   \n",
       "Austria                                       7.61             72.0   \n",
       "United Kingdom                               12.70             71.0   \n",
       "Sweden                                        1.13             74.0   \n",
       "Iceland                                      12.25             82.0   \n",
       "Australia                                    14.02             72.0   \n",
       "Ireland                                       4.20             60.0   \n",
       "Denmark                                       2.03             73.0   \n",
       "United States                                11.30             67.0   \n",
       "Norway                                        2.82             75.0   \n",
       "Switzerland                                   6.72             80.0   \n",
       "Luxembourg                                    3.47             66.0   \n",
       "\n",
       "                 Homicide rate  Household net adjusted disposable income  \\\n",
       "Country                                                                    \n",
       "Brazil                    25.5                                   11664.0   \n",
       "Mexico                    23.4                                   13085.0   \n",
       "Russia                    12.8                                   19292.0   \n",
       "Turkey                     1.2                                   14095.0   \n",
       "Hungary                    1.3                                   15442.0   \n",
       "Poland                     0.9                                   17852.0   \n",
       "Chile                      4.4                                   14533.0   \n",
       "Slovak Republic            1.2                                   17503.0   \n",
       "Czech Republic             0.8                                   18404.0   \n",
       "Estonia                    4.8                                   15167.0   \n",
       "Greece                     1.6                                   18575.0   \n",
       "Portugal                   1.1                                   20086.0   \n",
       "Slovenia                   0.4                                   19326.0   \n",
       "Spain                      0.6                                   22477.0   \n",
       "Korea                      1.1                                   19510.0   \n",
       "Italy                      0.7                                   25166.0   \n",
       "Japan                      0.3                                   26111.0   \n",
       "Israel                     2.3                                   22104.0   \n",
       "New Zealand                1.2                                   23815.0   \n",
       "France                     0.6                                   28799.0   \n",
       "Belgium                    1.1                                   28307.0   \n",
       "Germany                    0.5                                   31252.0   \n",
       "Finland                    1.4                                   27927.0   \n",
       "Canada                     1.5                                   29365.0   \n",
       "Netherlands                0.9                                   27888.0   \n",
       "Austria                    0.4                                   31173.0   \n",
       "United Kingdom             0.3                                   27029.0   \n",
       "Sweden                     0.7                                   29185.0   \n",
       "Iceland                    0.3                                   23965.0   \n",
       "Australia                  0.8                                   31588.0   \n",
       "Ireland                    0.8                                   23917.0   \n",
       "Denmark                    0.3                                   26491.0   \n",
       "United States              5.2                                   41355.0   \n",
       "Norway                     0.6                                   33492.0   \n",
       "Switzerland                0.5                                   33491.0   \n",
       "Luxembourg                 0.4                                   38951.0   \n",
       "\n",
       "                 Household net financial wealth          ...            \\\n",
       "Country                                                  ...             \n",
       "Brazil                                   6844.0          ...             \n",
       "Mexico                                   9056.0          ...             \n",
       "Russia                                   3412.0          ...             \n",
       "Turkey                                   3251.0          ...             \n",
       "Hungary                                 13277.0          ...             \n",
       "Poland                                  10919.0          ...             \n",
       "Chile                                   17733.0          ...             \n",
       "Slovak Republic                          8663.0          ...             \n",
       "Czech Republic                          17299.0          ...             \n",
       "Estonia                                  7680.0          ...             \n",
       "Greece                                  14579.0          ...             \n",
       "Portugal                                31245.0          ...             \n",
       "Slovenia                                18465.0          ...             \n",
       "Spain                                   24774.0          ...             \n",
       "Korea                                   29091.0          ...             \n",
       "Italy                                   54987.0          ...             \n",
       "Japan                                   86764.0          ...             \n",
       "Israel                                  52933.0          ...             \n",
       "New Zealand                             28290.0          ...             \n",
       "France                                  48741.0          ...             \n",
       "Belgium                                 83876.0          ...             \n",
       "Germany                                 50394.0          ...             \n",
       "Finland                                 18761.0          ...             \n",
       "Canada                                  67913.0          ...             \n",
       "Netherlands                             77961.0          ...             \n",
       "Austria                                 49887.0          ...             \n",
       "United Kingdom                          60778.0          ...             \n",
       "Sweden                                  60328.0          ...             \n",
       "Iceland                                 43045.0          ...             \n",
       "Australia                               47657.0          ...             \n",
       "Ireland                                 31580.0          ...             \n",
       "Denmark                                 44488.0          ...             \n",
       "United States                          145769.0          ...             \n",
       "Norway                                   8797.0          ...             \n",
       "Switzerland                            108823.0          ...             \n",
       "Luxembourg                              61765.0          ...             \n",
       "\n",
       "                 Time devoted to leisure and personal care  Voter turnout  \\\n",
       "Country                                                                     \n",
       "Brazil                                               14.97           79.0   \n",
       "Mexico                                               13.89           63.0   \n",
       "Russia                                               14.97           65.0   \n",
       "Turkey                                               13.42           88.0   \n",
       "Hungary                                              15.04           62.0   \n",
       "Poland                                               14.20           55.0   \n",
       "Chile                                                14.41           49.0   \n",
       "Slovak Republic                                      14.99           59.0   \n",
       "Czech Republic                                       14.98           59.0   \n",
       "Estonia                                              14.90           64.0   \n",
       "Greece                                               14.91           64.0   \n",
       "Portugal                                             14.95           58.0   \n",
       "Slovenia                                             14.62           52.0   \n",
       "Spain                                                16.06           69.0   \n",
       "Korea                                                14.63           76.0   \n",
       "Italy                                                14.98           75.0   \n",
       "Japan                                                14.93           53.0   \n",
       "Israel                                               14.48           68.0   \n",
       "New Zealand                                          14.87           77.0   \n",
       "France                                               15.33           80.0   \n",
       "Belgium                                              15.71           89.0   \n",
       "Germany                                              15.31           72.0   \n",
       "Finland                                              14.89           69.0   \n",
       "Canada                                               14.25           61.0   \n",
       "Netherlands                                          15.44           75.0   \n",
       "Austria                                              14.46           75.0   \n",
       "United Kingdom                                       14.83           66.0   \n",
       "Sweden                                               15.11           86.0   \n",
       "Iceland                                              14.61           81.0   \n",
       "Australia                                            14.41           93.0   \n",
       "Ireland                                              15.19           70.0   \n",
       "Denmark                                              16.06           88.0   \n",
       "United States                                        14.27           68.0   \n",
       "Norway                                               15.56           78.0   \n",
       "Switzerland                                          14.98           49.0   \n",
       "Luxembourg                                           15.12           91.0   \n",
       "\n",
       "                 Water quality  Years in education  \\\n",
       "Country                                              \n",
       "Brazil                    72.0                16.3   \n",
       "Mexico                    67.0                14.4   \n",
       "Russia                    56.0                16.0   \n",
       "Turkey                    62.0                16.4   \n",
       "Hungary                   77.0                17.6   \n",
       "Poland                    79.0                18.4   \n",
       "Chile                     73.0                16.5   \n",
       "Slovak Republic           81.0                16.3   \n",
       "Czech Republic            85.0                18.1   \n",
       "Estonia                   79.0                17.5   \n",
       "Greece                    69.0                18.6   \n",
       "Portugal                  86.0                17.6   \n",
       "Slovenia                  88.0                18.4   \n",
       "Spain                     71.0                17.6   \n",
       "Korea                     78.0                17.5   \n",
       "Italy                     71.0                16.8   \n",
       "Japan                     85.0                16.3   \n",
       "Israel                    68.0                15.8   \n",
       "New Zealand               89.0                18.1   \n",
       "France                    82.0                16.4   \n",
       "Belgium                   87.0                18.9   \n",
       "Germany                   95.0                18.2   \n",
       "Finland                   94.0                19.7   \n",
       "Canada                    91.0                17.2   \n",
       "Netherlands               92.0                18.7   \n",
       "Austria                   94.0                17.0   \n",
       "United Kingdom            88.0                16.4   \n",
       "Sweden                    95.0                19.3   \n",
       "Iceland                   97.0                19.8   \n",
       "Australia                 91.0                19.4   \n",
       "Ireland                   80.0                17.6   \n",
       "Denmark                   94.0                19.4   \n",
       "United States             85.0                17.2   \n",
       "Norway                    94.0                17.9   \n",
       "Switzerland               96.0                17.3   \n",
       "Luxembourg                86.0                15.1   \n",
       "\n",
       "                                                Subject Descriptor  \\\n",
       "Country                                                              \n",
       "Brazil           Gross domestic product per capita, current prices   \n",
       "Mexico           Gross domestic product per capita, current prices   \n",
       "Russia           Gross domestic product per capita, current prices   \n",
       "Turkey           Gross domestic product per capita, current prices   \n",
       "Hungary          Gross domestic product per capita, current prices   \n",
       "Poland           Gross domestic product per capita, current prices   \n",
       "Chile            Gross domestic product per capita, current prices   \n",
       "Slovak Republic  Gross domestic product per capita, current prices   \n",
       "Czech Republic   Gross domestic product per capita, current prices   \n",
       "Estonia          Gross domestic product per capita, current prices   \n",
       "Greece           Gross domestic product per capita, current prices   \n",
       "Portugal         Gross domestic product per capita, current prices   \n",
       "Slovenia         Gross domestic product per capita, current prices   \n",
       "Spain            Gross domestic product per capita, current prices   \n",
       "Korea            Gross domestic product per capita, current prices   \n",
       "Italy            Gross domestic product per capita, current prices   \n",
       "Japan            Gross domestic product per capita, current prices   \n",
       "Israel           Gross domestic product per capita, current prices   \n",
       "New Zealand      Gross domestic product per capita, current prices   \n",
       "France           Gross domestic product per capita, current prices   \n",
       "Belgium          Gross domestic product per capita, current prices   \n",
       "Germany          Gross domestic product per capita, current prices   \n",
       "Finland          Gross domestic product per capita, current prices   \n",
       "Canada           Gross domestic product per capita, current prices   \n",
       "Netherlands      Gross domestic product per capita, current prices   \n",
       "Austria          Gross domestic product per capita, current prices   \n",
       "United Kingdom   Gross domestic product per capita, current prices   \n",
       "Sweden           Gross domestic product per capita, current prices   \n",
       "Iceland          Gross domestic product per capita, current prices   \n",
       "Australia        Gross domestic product per capita, current prices   \n",
       "Ireland          Gross domestic product per capita, current prices   \n",
       "Denmark          Gross domestic product per capita, current prices   \n",
       "United States    Gross domestic product per capita, current prices   \n",
       "Norway           Gross domestic product per capita, current prices   \n",
       "Switzerland      Gross domestic product per capita, current prices   \n",
       "Luxembourg       Gross domestic product per capita, current prices   \n",
       "\n",
       "                        Units  Scale  \\\n",
       "Country                                \n",
       "Brazil           U.S. dollars  Units   \n",
       "Mexico           U.S. dollars  Units   \n",
       "Russia           U.S. dollars  Units   \n",
       "Turkey           U.S. dollars  Units   \n",
       "Hungary          U.S. dollars  Units   \n",
       "Poland           U.S. dollars  Units   \n",
       "Chile            U.S. dollars  Units   \n",
       "Slovak Republic  U.S. dollars  Units   \n",
       "Czech Republic   U.S. dollars  Units   \n",
       "Estonia          U.S. dollars  Units   \n",
       "Greece           U.S. dollars  Units   \n",
       "Portugal         U.S. dollars  Units   \n",
       "Slovenia         U.S. dollars  Units   \n",
       "Spain            U.S. dollars  Units   \n",
       "Korea            U.S. dollars  Units   \n",
       "Italy            U.S. dollars  Units   \n",
       "Japan            U.S. dollars  Units   \n",
       "Israel           U.S. dollars  Units   \n",
       "New Zealand      U.S. dollars  Units   \n",
       "France           U.S. dollars  Units   \n",
       "Belgium          U.S. dollars  Units   \n",
       "Germany          U.S. dollars  Units   \n",
       "Finland          U.S. dollars  Units   \n",
       "Canada           U.S. dollars  Units   \n",
       "Netherlands      U.S. dollars  Units   \n",
       "Austria          U.S. dollars  Units   \n",
       "United Kingdom   U.S. dollars  Units   \n",
       "Sweden           U.S. dollars  Units   \n",
       "Iceland          U.S. dollars  Units   \n",
       "Australia        U.S. dollars  Units   \n",
       "Ireland          U.S. dollars  Units   \n",
       "Denmark          U.S. dollars  Units   \n",
       "United States    U.S. dollars  Units   \n",
       "Norway           U.S. dollars  Units   \n",
       "Switzerland      U.S. dollars  Units   \n",
       "Luxembourg       U.S. dollars  Units   \n",
       "\n",
       "                                     Country/Series-specific Notes  \\\n",
       "Country                                                              \n",
       "Brazil           See notes for:  Gross domestic product, curren...   \n",
       "Mexico           See notes for:  Gross domestic product, curren...   \n",
       "Russia           See notes for:  Gross domestic product, curren...   \n",
       "Turkey           See notes for:  Gross domestic product, curren...   \n",
       "Hungary          See notes for:  Gross domestic product, curren...   \n",
       "Poland           See notes for:  Gross domestic product, curren...   \n",
       "Chile            See notes for:  Gross domestic product, curren...   \n",
       "Slovak Republic  See notes for:  Gross domestic product, curren...   \n",
       "Czech Republic   See notes for:  Gross domestic product, curren...   \n",
       "Estonia          See notes for:  Gross domestic product, curren...   \n",
       "Greece           See notes for:  Gross domestic product, curren...   \n",
       "Portugal         See notes for:  Gross domestic product, curren...   \n",
       "Slovenia         See notes for:  Gross domestic product, curren...   \n",
       "Spain            See notes for:  Gross domestic product, curren...   \n",
       "Korea            See notes for:  Gross domestic product, curren...   \n",
       "Italy            See notes for:  Gross domestic product, curren...   \n",
       "Japan            See notes for:  Gross domestic product, curren...   \n",
       "Israel           See notes for:  Gross domestic product, curren...   \n",
       "New Zealand      See notes for:  Gross domestic product, curren...   \n",
       "France           See notes for:  Gross domestic product, curren...   \n",
       "Belgium          See notes for:  Gross domestic product, curren...   \n",
       "Germany          See notes for:  Gross domestic product, curren...   \n",
       "Finland          See notes for:  Gross domestic product, curren...   \n",
       "Canada           See notes for:  Gross domestic product, curren...   \n",
       "Netherlands      See notes for:  Gross domestic product, curren...   \n",
       "Austria          See notes for:  Gross domestic product, curren...   \n",
       "United Kingdom   See notes for:  Gross domestic product, curren...   \n",
       "Sweden           See notes for:  Gross domestic product, curren...   \n",
       "Iceland          See notes for:  Gross domestic product, curren...   \n",
       "Australia        See notes for:  Gross domestic product, curren...   \n",
       "Ireland          See notes for:  Gross domestic product, curren...   \n",
       "Denmark          See notes for:  Gross domestic product, curren...   \n",
       "United States    See notes for:  Gross domestic product, curren...   \n",
       "Norway           See notes for:  Gross domestic product, curren...   \n",
       "Switzerland      See notes for:  Gross domestic product, curren...   \n",
       "Luxembourg       See notes for:  Gross domestic product, curren...   \n",
       "\n",
       "                 GDP per capita  Estimates Start After  \n",
       "Country                                                 \n",
       "Brazil                 8669.998                 2014.0  \n",
       "Mexico                 9009.280                 2015.0  \n",
       "Russia                 9054.914                 2015.0  \n",
       "Turkey                 9437.372                 2013.0  \n",
       "Hungary               12239.894                 2015.0  \n",
       "Poland                12495.334                 2014.0  \n",
       "Chile                 13340.905                 2014.0  \n",
       "Slovak Republic       15991.736                 2015.0  \n",
       "Czech Republic        17256.918                 2015.0  \n",
       "Estonia               17288.083                 2014.0  \n",
       "Greece                18064.288                 2014.0  \n",
       "Portugal              19121.592                 2014.0  \n",
       "Slovenia              20732.482                 2015.0  \n",
       "Spain                 25864.721                 2014.0  \n",
       "Korea                 27195.197                 2014.0  \n",
       "Italy                 29866.581                 2015.0  \n",
       "Japan                 32485.545                 2015.0  \n",
       "Israel                35343.336                 2015.0  \n",
       "New Zealand           37044.891                 2015.0  \n",
       "France                37675.006                 2015.0  \n",
       "Belgium               40106.632                 2014.0  \n",
       "Germany               40996.511                 2014.0  \n",
       "Finland               41973.988                 2014.0  \n",
       "Canada                43331.961                 2015.0  \n",
       "Netherlands           43603.115                 2014.0  \n",
       "Austria               43724.031                 2015.0  \n",
       "United Kingdom        43770.688                 2015.0  \n",
       "Sweden                49866.266                 2014.0  \n",
       "Iceland               50854.583                 2014.0  \n",
       "Australia             50961.865                 2014.0  \n",
       "Ireland               51350.744                 2014.0  \n",
       "Denmark               52114.165                 2015.0  \n",
       "United States         55805.204                 2015.0  \n",
       "Norway                74822.106                 2015.0  \n",
       "Switzerland           80675.308                 2015.0  \n",
       "Luxembourg           101994.093                 2014.0  \n",
       "\n",
       "[36 rows x 30 columns]"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "full_country_stats = pd.merge(left=oecd_bli, right=gdp_per_capita, left_index=True, right_index=True)\n",
    "full_country_stats.sort_values(by=\"GDP per capita\", inplace=True)\n",
    "full_country_stats"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "GDP per capita       55805.204\n",
       "Life satisfaction        7.200\n",
       "Name: United States, dtype: float64"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "full_country_stats[[\"GDP per capita\", 'Life satisfaction']].loc[\"United States\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "remove_indices = [0, 1, 6, 8, 33, 34, 35]\n",
    "keep_indices = list(set(range(36)) - set(remove_indices))\n",
    "\n",
    "sample_data = full_country_stats[[\"GDP per capita\", 'Life satisfaction']].iloc[keep_indices]\n",
    "missing_data = full_country_stats[[\"GDP per capita\", 'Life satisfaction']].iloc[remove_indices]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 14780 characters]\n",
      "text/plain": [
       "<Figure size 360x216 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "ax = sample_data.plot(kind='scatter', x=\"GDP per capita\", y='Life satisfaction', figsize=(5,3))\n",
    "ax.set(xlabel='1인당 GDP', ylabel='삶의 만족도')\n",
    "plt.axis([0, 60000, 0, 10])\n",
    "position_text = {\n",
    "    \"Hungary\": (5000, 1, '헝가리'),\n",
    "    \"Korea\": (18000, 1.7, '대한민국'),\n",
    "    \"France\": (29000, 2.4, '프랑스'),\n",
    "    \"Australia\": (40000, 3.0, '호주'),\n",
    "    \"United States\": (52000, 3.8, '미국'),\n",
    "}\n",
    "for country, pos_text in position_text.items():\n",
    "    pos_data_x, pos_data_y = sample_data.loc[country]\n",
    "    country = \"U.S.\" if country == \"United States\" else country\n",
    "    plt.annotate(pos_text[2], xy=(pos_data_x, pos_data_y), xytext=pos_text[:2],\n",
    "            arrowprops=dict(facecolor='black', width=0.5, shrink=0.1, headwidth=5))\n",
    "    plt.plot(pos_data_x, pos_data_y, \"ro\")\n",
    "save_fig('money_happy_scatterplot')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "sample_data.to_csv(os.path.join(\"datasets\", \"lifesat\", \"lifesat.csv\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>GDP per capita</th>\n",
       "      <th>Life satisfaction</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Country</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Korea</th>\n",
       "      <td>27195.197</td>\n",
       "      <td>5.8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Australia</th>\n",
       "      <td>50961.865</td>\n",
       "      <td>7.3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Hungary</th>\n",
       "      <td>12239.894</td>\n",
       "      <td>4.9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>United States</th>\n",
       "      <td>55805.204</td>\n",
       "      <td>7.2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>France</th>\n",
       "      <td>37675.006</td>\n",
       "      <td>6.5</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "               GDP per capita  Life satisfaction\n",
       "Country                                         \n",
       "Korea               27195.197                5.8\n",
       "Australia           50961.865                7.3\n",
       "Hungary             12239.894                4.9\n",
       "United States       55805.204                7.2\n",
       "France              37675.006                6.5"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sample_data.loc[list(position_text.keys())]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 18272 characters]\n",
      "text/plain": [
       "<Figure size 360x216 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import numpy as np\n",
    "\n",
    "ax = sample_data.plot(kind='scatter', x=\"GDP per capita\", y='Life satisfaction', figsize=(5,3))\n",
    "ax.set(xlabel='1인당 GDP', ylabel='삶의 만족도')\n",
    "plt.axis([0, 60000, 0, 10])\n",
    "X=np.linspace(0, 60000, 1000)\n",
    "plt.plot(X, 2*X/100000, \"r\")\n",
    "plt.text(40000, 2.7, r\"$\\theta_0 = 0$\", fontsize=14, color=\"r\")\n",
    "plt.text(40000, 1.8, r\"$\\theta_1 = 2 \\times 10^{-5}$\", fontsize=14, color=\"r\")\n",
    "plt.plot(X, 8 - 5*X/100000, \"g\")\n",
    "plt.text(5000, 9.1, r\"$\\theta_0 = 8$\", fontsize=14, color=\"g\")\n",
    "plt.text(5000, 8.2, r\"$\\theta_1 = -5 \\times 10^{-5}$\", fontsize=14, color=\"g\")\n",
    "plt.plot(X, 4 + 5*X/100000, \"b\")\n",
    "plt.text(5000, 3.5, r\"$\\theta_0 = 4$\", fontsize=14, color=\"b\")\n",
    "plt.text(5000, 2.6, r\"$\\theta_1 = 5 \\times 10^{-5}$\", fontsize=14, color=\"b\")\n",
    "save_fig('tweaking_model_params_plot')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(4.853052800266436, 4.911544589158483e-05)"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn import linear_model\n",
    "lin1 = linear_model.LinearRegression()\n",
    "Xsample = np.c_[sample_data[\"GDP per capita\"]]\n",
    "ysample = np.c_[sample_data[\"Life satisfaction\"]]\n",
    "lin1.fit(Xsample, ysample)\n",
    "t0, t1 = lin1.intercept_[0], lin1.coef_[0][0]\n",
    "t0, t1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 12540 characters]\n",
      "text/plain": [
       "<Figure size 360x216 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "ax = sample_data.plot(kind='scatter', x=\"GDP per capita\", y='Life satisfaction', figsize=(5,3))\n",
    "ax.set(xlabel='1인당 GDP', ylabel='삶의 만족도')\n",
    "plt.axis([0, 60000, 0, 10])\n",
    "X=np.linspace(0, 60000, 1000)\n",
    "plt.plot(X, t0 + t1*X, \"b\")\n",
    "plt.text(5000, 3.1, r\"$\\theta_0 = 4.85$\", fontsize=14, color=\"b\")\n",
    "plt.text(5000, 2.2, r\"$\\theta_1 = 4.91 \\times 10^{-5}$\", fontsize=14, color=\"b\")\n",
    "save_fig('best_fit_model_plot')\n",
    "plt.show()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "22587.49\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "5.96244744318815"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cyprus_gdp_per_capita = gdp_per_capita.loc[\"Cyprus\"][\"GDP per capita\"]\n",
    "print(cyprus_gdp_per_capita)\n",
    "cyprus_predicted_life_satisfaction = lin1.predict(cyprus_gdp_per_capita)[0][0]\n",
    "cyprus_predicted_life_satisfaction"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 13404 characters]\n",
      "text/plain": [
       "<Figure size 360x216 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "ax = sample_data.plot(kind='scatter', x=\"GDP per capita\", y='Life satisfaction', figsize=(5,3), s=1)\n",
    "ax.set(xlabel='1인당 GDP', ylabel='삶의 만족도')\n",
    "X=np.linspace(0, 60000, 1000)\n",
    "plt.plot(X, t0 + t1*X, \"b\")\n",
    "plt.axis([0, 60000, 0, 10])\n",
    "plt.text(5000, 7.5, r\"$\\theta_0 = 4.85$\", fontsize=14, color=\"b\")\n",
    "plt.text(5000, 6.6, r\"$\\theta_1 = 4.91 \\times 10^{-5}$\", fontsize=14, color=\"b\")\n",
    "plt.plot([cyprus_gdp_per_capita, cyprus_gdp_per_capita], [0, cyprus_predicted_life_satisfaction], \"r--\")\n",
    "plt.text(25000, 5.0, r\"예측 = 5.96\", fontsize=14, color=\"b\")\n",
    "plt.plot(cyprus_gdp_per_capita, cyprus_predicted_life_satisfaction, \"ro\")\n",
    "save_fig('cyprus_prediction_plot')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>GDP per capita</th>\n",
       "      <th>Life satisfaction</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Country</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Portugal</th>\n",
       "      <td>19121.592</td>\n",
       "      <td>5.1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Slovenia</th>\n",
       "      <td>20732.482</td>\n",
       "      <td>5.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Spain</th>\n",
       "      <td>25864.721</td>\n",
       "      <td>6.5</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          GDP per capita  Life satisfaction\n",
       "Country                                    \n",
       "Portugal       19121.592                5.1\n",
       "Slovenia       20732.482                5.7\n",
       "Spain          25864.721                6.5"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sample_data[7:10]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "5.766666666666667"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(5.1+5.7+6.5)/3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>GDP per capita</th>\n",
       "      <th>Life satisfaction</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Country</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Brazil</th>\n",
       "      <td>8669.998</td>\n",
       "      <td>7.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Mexico</th>\n",
       "      <td>9009.280</td>\n",
       "      <td>6.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Chile</th>\n",
       "      <td>13340.905</td>\n",
       "      <td>6.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Czech Republic</th>\n",
       "      <td>17256.918</td>\n",
       "      <td>6.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Norway</th>\n",
       "      <td>74822.106</td>\n",
       "      <td>7.4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Switzerland</th>\n",
       "      <td>80675.308</td>\n",
       "      <td>7.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Luxembourg</th>\n",
       "      <td>101994.093</td>\n",
       "      <td>6.9</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                GDP per capita  Life satisfaction\n",
       "Country                                          \n",
       "Brazil                8669.998                7.0\n",
       "Mexico                9009.280                6.7\n",
       "Chile                13340.905                6.7\n",
       "Czech Republic       17256.918                6.5\n",
       "Norway               74822.106                7.4\n",
       "Switzerland          80675.308                7.5\n",
       "Luxembourg          101994.093                6.9"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "missing_data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [],
   "source": [
    "position_text2 = {\n",
    "    \"Brazil\": (1000, 9.0, '브라질'),\n",
    "    \"Mexico\": (11000, 9.0, '멕시코'),\n",
    "    \"Chile\": (25000, 9.0, '칠레'),\n",
    "    \"Czech Republic\": (35000, 9.0, '체코'),\n",
    "    \"Norway\": (60000, 3, '노르웨이'),\n",
    "    \"Switzerland\": (72000, 3.0, '스위스'),\n",
    "    \"Luxembourg\": (90000, 3.0, '룩셈부르크'),\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 25060 characters]\n",
      "text/plain": [
       "<Figure size 576x216 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "ax = sample_data.plot(kind='scatter', x=\"GDP per capita\", y='Life satisfaction', figsize=(8,3))\n",
    "ax.set(xlabel='1인당 GDP', ylabel='삶의 만족도')\n",
    "plt.axis([0, 110000, 0, 10])\n",
    "\n",
    "for country, pos_text in position_text2.items():\n",
    "    pos_data_x, pos_data_y = missing_data.loc[country]\n",
    "    plt.annotate(pos_text[2], xy=(pos_data_x, pos_data_y), xytext=pos_text[:2],\n",
    "            arrowprops=dict(facecolor='black', width=0.5, shrink=0.1, headwidth=5))\n",
    "    plt.plot(pos_data_x, pos_data_y, \"rs\")\n",
    "\n",
    "X=np.linspace(0, 110000, 1000)\n",
    "plt.plot(X, t0 + t1*X, \"b:\")\n",
    "\n",
    "lin_reg_full = linear_model.LinearRegression()\n",
    "Xfull = np.c_[full_country_stats[\"GDP per capita\"]]\n",
    "yfull = np.c_[full_country_stats[\"Life satisfaction\"]]\n",
    "lin_reg_full.fit(Xfull, yfull)\n",
    "\n",
    "t0full, t1full = lin_reg_full.intercept_[0], lin_reg_full.coef_[0][0]\n",
    "X = np.linspace(0, 110000, 1000)\n",
    "plt.plot(X, t0full + t1full * X, \"k\")\n",
    "\n",
    "save_fig('representative_training_data_scatterplot')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/haesun/anaconda3/envs/handson-ml/lib/python3.5/site-packages/numpy/core/_methods.py:116: RuntimeWarning: overflow encountered in multiply\n",
      "  x = um.multiply(x, x, out=x)\n",
      "/home/haesun/anaconda3/envs/handson-ml/lib/python3.5/site-packages/numpy/core/_methods.py:117: RuntimeWarning: overflow encountered in reduce\n",
      "  ret = umr_sum(x, axis, dtype, out, keepdims)\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 17096 characters]\n",
      "text/plain": [
       "<Figure size 576x216 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "ax = full_country_stats.plot(kind='scatter', x=\"GDP per capita\", y='Life satisfaction', figsize=(8,3))\n",
    "ax.set(xlabel='1인당 GDP', ylabel='삶의 만족도')\n",
    "plt.axis([0, 110000, 0, 10])\n",
    "\n",
    "from sklearn import preprocessing\n",
    "from sklearn import pipeline\n",
    "\n",
    "poly = preprocessing.PolynomialFeatures(degree=60, include_bias=False)\n",
    "scaler = preprocessing.StandardScaler()\n",
    "lin_reg2 = linear_model.LinearRegression()\n",
    "\n",
    "pipeline_reg = pipeline.Pipeline([('poly', poly), ('scal', scaler), ('lin', lin_reg2)])\n",
    "pipeline_reg.fit(Xfull, yfull)\n",
    "curve = pipeline_reg.predict(X[:, np.newaxis])\n",
    "plt.plot(X, curve)\n",
    "save_fig('overfitting_model_plot')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Country\n",
       "New Zealand    7.3\n",
       "Sweden         7.2\n",
       "Norway         7.4\n",
       "Switzerland    7.5\n",
       "Name: Life satisfaction, dtype: float64"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "full_country_stats.loc[[c for c in full_country_stats.index if \"W\" in c.upper()]][\"Life satisfaction\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Subject Descriptor</th>\n",
       "      <th>Units</th>\n",
       "      <th>Scale</th>\n",
       "      <th>Country/Series-specific Notes</th>\n",
       "      <th>GDP per capita</th>\n",
       "      <th>Estimates Start After</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Country</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Botswana</th>\n",
       "      <td>Gross domestic product per capita, current prices</td>\n",
       "      <td>U.S. dollars</td>\n",
       "      <td>Units</td>\n",
       "      <td>See notes for:  Gross domestic product, curren...</td>\n",
       "      <td>6040.957</td>\n",
       "      <td>2008.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Kuwait</th>\n",
       "      <td>Gross domestic product per capita, current prices</td>\n",
       "      <td>U.S. dollars</td>\n",
       "      <td>Units</td>\n",
       "      <td>See notes for:  Gross domestic product, curren...</td>\n",
       "      <td>29363.027</td>\n",
       "      <td>2014.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Malawi</th>\n",
       "      <td>Gross domestic product per capita, current prices</td>\n",
       "      <td>U.S. dollars</td>\n",
       "      <td>Units</td>\n",
       "      <td>See notes for:  Gross domestic product, curren...</td>\n",
       "      <td>354.275</td>\n",
       "      <td>2011.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>New Zealand</th>\n",
       "      <td>Gross domestic product per capita, current prices</td>\n",
       "      <td>U.S. dollars</td>\n",
       "      <td>Units</td>\n",
       "      <td>See notes for:  Gross domestic product, curren...</td>\n",
       "      <td>37044.891</td>\n",
       "      <td>2015.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Norway</th>\n",
       "      <td>Gross domestic product per capita, current prices</td>\n",
       "      <td>U.S. dollars</td>\n",
       "      <td>Units</td>\n",
       "      <td>See notes for:  Gross domestic product, curren...</td>\n",
       "      <td>74822.106</td>\n",
       "      <td>2015.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                            Subject Descriptor         Units  \\\n",
       "Country                                                                        \n",
       "Botswana     Gross domestic product per capita, current prices  U.S. dollars   \n",
       "Kuwait       Gross domestic product per capita, current prices  U.S. dollars   \n",
       "Malawi       Gross domestic product per capita, current prices  U.S. dollars   \n",
       "New Zealand  Gross domestic product per capita, current prices  U.S. dollars   \n",
       "Norway       Gross domestic product per capita, current prices  U.S. dollars   \n",
       "\n",
       "             Scale                      Country/Series-specific Notes  \\\n",
       "Country                                                                 \n",
       "Botswana     Units  See notes for:  Gross domestic product, curren...   \n",
       "Kuwait       Units  See notes for:  Gross domestic product, curren...   \n",
       "Malawi       Units  See notes for:  Gross domestic product, curren...   \n",
       "New Zealand  Units  See notes for:  Gross domestic product, curren...   \n",
       "Norway       Units  See notes for:  Gross domestic product, curren...   \n",
       "\n",
       "             GDP per capita  Estimates Start After  \n",
       "Country                                             \n",
       "Botswana           6040.957                 2008.0  \n",
       "Kuwait            29363.027                 2014.0  \n",
       "Malawi              354.275                 2011.0  \n",
       "New Zealand       37044.891                 2015.0  \n",
       "Norway            74822.106                 2015.0  "
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "gdp_per_capita.loc[[c for c in gdp_per_capita.index if \"W\" in c.upper()]].head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 26376 characters]\n",
      "text/plain": [
       "<Figure size 576x216 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(8,3))\n",
    "\n",
    "plt.xlabel(\"1인당 GDP\")\n",
    "plt.ylabel('삶의 만족도')\n",
    "\n",
    "plt.plot(list(sample_data[\"GDP per capita\"]), list(sample_data[\"Life satisfaction\"]), \"bo\")\n",
    "plt.plot(list(missing_data[\"GDP per capita\"]), list(missing_data[\"Life satisfaction\"]), \"rs\")\n",
    "\n",
    "X = np.linspace(0, 110000, 1000)\n",
    "plt.plot(X, t0full + t1full * X, \"r--\", label=\"모든 데이터로 만든 선형 모델\")\n",
    "plt.plot(X, t0 + t1*X, \"b:\", label=\"일부 데이터로 만든 선형 모델\")\n",
    "\n",
    "ridge = linear_model.Ridge(alpha=10**9.5)\n",
    "Xsample = np.c_[sample_data[\"GDP per capita\"]]\n",
    "ysample = np.c_[sample_data[\"Life satisfaction\"]]\n",
    "ridge.fit(Xsample, ysample)\n",
    "t0ridge, t1ridge = ridge.intercept_[0], ridge.coef_[0][0]\n",
    "plt.plot(X, t0ridge + t1ridge * X, \"b\", label=\"일부 데이터로 만든 규제가 적용된 선형 모델\")\n",
    "\n",
    "plt.legend(loc=\"lower right\")\n",
    "plt.axis([0, 110000, 0, 10])\n",
    "save_fig('ridge_model_plot')\n",
    "plt.show()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.5"
  },
  "nav_menu": {},
  "toc": {
   "navigate_menu": true,
   "number_sections": true,
   "sideBar": true,
   "threshold": 6,
   "toc_cell": false,
   "toc_section_display": "block",
   "toc_window_display": true
  },
  "toc_position": {
   "height": "616px",
   "left": "0px",
   "right": "20px",
   "top": "106px",
   "width": "213px"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
