You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3727 lines
149KB

  1. {
  2. "cells": [
  3. {
  4. "cell_type": "code",
  5. "execution_count": 1,
  6. "metadata": {
  7. "collapsed": false
  8. },
  9. "outputs": [],
  10. "source": [
  11. "from pyspark.sql import SQLContext\n",
  12. "\n",
  13. "LOCAL_PATH = 'file:///Users/Karl-Loic/Documents/Columbia-University/Fall-2016/Big-Data-Analytics/final-project/kiva-dig/'"
  14. ]
  15. },
  16. {
  17. "cell_type": "code",
  18. "execution_count": 2,
  19. "metadata": {
  20. "collapsed": true
  21. },
  22. "outputs": [],
  23. "source": [
  24. "sql_ctx = SQLContext(sc)"
  25. ]
  26. },
  27. {
  28. "cell_type": "code",
  29. "execution_count": 3,
  30. "metadata": {
  31. "collapsed": false
  32. },
  33. "outputs": [],
  34. "source": [
  35. "# TODO: Create permanent database tables for reuse\n",
  36. "# Remove previously created metastore DB\n",
  37. "import os, shutil\n",
  38. "\n",
  39. "if os.path.exists(LOCAL_PATH + 'metastore_db/'):\n",
  40. " shutil.rmtree('metastore_db/')\n",
  41. "loans = sql_ctx.read.json(LOCAL_PATH + 'kiva-data/loans.json')"
  42. ]
  43. },
  44. {
  45. "cell_type": "code",
  46. "execution_count": 4,
  47. "metadata": {
  48. "collapsed": false
  49. },
  50. "outputs": [
  51. {
  52. "data": {
  53. "text/plain": [
  54. "1014130"
  55. ]
  56. },
  57. "execution_count": 4,
  58. "metadata": {},
  59. "output_type": "execute_result"
  60. }
  61. ],
  62. "source": [
  63. "loans.count()"
  64. ]
  65. },
  66. {
  67. "cell_type": "code",
  68. "execution_count": 5,
  69. "metadata": {
  70. "collapsed": false
  71. },
  72. "outputs": [
  73. {
  74. "name": "stdout",
  75. "output_type": "stream",
  76. "text": [
  77. "root\n",
  78. " |-- activity: string (nullable = true)\n",
  79. " |-- basket_amount: long (nullable = true)\n",
  80. " |-- bonus_credit_eligibility: boolean (nullable = true)\n",
  81. " |-- borrowers: array (nullable = true)\n",
  82. " | |-- element: struct (containsNull = true)\n",
  83. " | | |-- first_name: string (nullable = true)\n",
  84. " | | |-- gender: string (nullable = true)\n",
  85. " | | |-- last_name: string (nullable = true)\n",
  86. " | | |-- pictured: boolean (nullable = true)\n",
  87. " |-- currency_exchange_loss_amount: double (nullable = true)\n",
  88. " |-- delinquent: boolean (nullable = true)\n",
  89. " |-- description: struct (nullable = true)\n",
  90. " | |-- languages: array (nullable = true)\n",
  91. " | | |-- element: string (containsNull = true)\n",
  92. " | |-- texts: struct (nullable = true)\n",
  93. " | | |-- ar: string (nullable = true)\n",
  94. " | | |-- en: string (nullable = true)\n",
  95. " | | |-- es: string (nullable = true)\n",
  96. " | | |-- fr: string (nullable = true)\n",
  97. " | | |-- id: string (nullable = true)\n",
  98. " | | |-- mn: string (nullable = true)\n",
  99. " | | |-- pt: string (nullable = true)\n",
  100. " | | |-- ru: string (nullable = true)\n",
  101. " | | |-- vi: string (nullable = true)\n",
  102. " |-- funded_amount: long (nullable = true)\n",
  103. " |-- funded_date: string (nullable = true)\n",
  104. " |-- id: long (nullable = true)\n",
  105. " |-- image: struct (nullable = true)\n",
  106. " | |-- id: long (nullable = true)\n",
  107. " | |-- template_id: long (nullable = true)\n",
  108. " |-- journal_totals: struct (nullable = true)\n",
  109. " | |-- bulkEntries: long (nullable = true)\n",
  110. " | |-- entries: long (nullable = true)\n",
  111. " |-- lender_count: long (nullable = true)\n",
  112. " |-- loan_amount: long (nullable = true)\n",
  113. " |-- location: struct (nullable = true)\n",
  114. " | |-- country: string (nullable = true)\n",
  115. " | |-- country_code: string (nullable = true)\n",
  116. " | |-- geo: struct (nullable = true)\n",
  117. " | | |-- level: string (nullable = true)\n",
  118. " | | |-- pairs: string (nullable = true)\n",
  119. " | | |-- type: string (nullable = true)\n",
  120. " | |-- town: string (nullable = true)\n",
  121. " |-- name: string (nullable = true)\n",
  122. " |-- paid_amount: double (nullable = true)\n",
  123. " |-- paid_date: string (nullable = true)\n",
  124. " |-- partner_id: long (nullable = true)\n",
  125. " |-- payments: array (nullable = true)\n",
  126. " | |-- element: struct (containsNull = true)\n",
  127. " | | |-- amount: double (nullable = true)\n",
  128. " | | |-- currency_exchange_loss_amount: double (nullable = true)\n",
  129. " | | |-- local_amount: double (nullable = true)\n",
  130. " | | |-- payment_id: long (nullable = true)\n",
  131. " | | |-- processed_date: string (nullable = true)\n",
  132. " | | |-- rounded_local_amount: double (nullable = true)\n",
  133. " | | |-- settlement_date: string (nullable = true)\n",
  134. " |-- planned_expiration_date: string (nullable = true)\n",
  135. " |-- posted_date: string (nullable = true)\n",
  136. " |-- sector: string (nullable = true)\n",
  137. " |-- status: string (nullable = true)\n",
  138. " |-- tags: array (nullable = true)\n",
  139. " | |-- element: struct (containsNull = true)\n",
  140. " | | |-- name: string (nullable = true)\n",
  141. " |-- terms: struct (nullable = true)\n",
  142. " | |-- disbursal_amount: double (nullable = true)\n",
  143. " | |-- disbursal_currency: string (nullable = true)\n",
  144. " | |-- disbursal_date: string (nullable = true)\n",
  145. " | |-- loan_amount: long (nullable = true)\n",
  146. " | |-- local_payments: array (nullable = true)\n",
  147. " | | |-- element: struct (containsNull = true)\n",
  148. " | | | |-- amount: double (nullable = true)\n",
  149. " | | | |-- due_date: string (nullable = true)\n",
  150. " | |-- loss_liability: struct (nullable = true)\n",
  151. " | | |-- currency_exchange: string (nullable = true)\n",
  152. " | | |-- currency_exchange_coverage_rate: double (nullable = true)\n",
  153. " | | |-- nonpayment: string (nullable = true)\n",
  154. " | |-- repayment_interval: string (nullable = true)\n",
  155. " | |-- repayment_term: long (nullable = true)\n",
  156. " | |-- scheduled_payments: array (nullable = true)\n",
  157. " | | |-- element: struct (containsNull = true)\n",
  158. " | | | |-- amount: double (nullable = true)\n",
  159. " | | | |-- due_date: string (nullable = true)\n",
  160. " |-- themes: array (nullable = true)\n",
  161. " | |-- element: string (containsNull = true)\n",
  162. " |-- translator: struct (nullable = true)\n",
  163. " | |-- byline: string (nullable = true)\n",
  164. " | |-- image: long (nullable = true)\n",
  165. " |-- use: string (nullable = true)\n",
  166. " |-- video: struct (nullable = true)\n",
  167. " | |-- id: long (nullable = true)\n",
  168. " | |-- thumbnailImageId: long (nullable = true)\n",
  169. " | |-- title: string (nullable = true)\n",
  170. " | |-- youtubeId: string (nullable = true)\n",
  171. "\n"
  172. ]
  173. }
  174. ],
  175. "source": [
  176. "loans.printSchema()"
  177. ]
  178. },
  179. {
  180. "cell_type": "code",
  181. "execution_count": 13,
  182. "metadata": {
  183. "collapsed": false
  184. },
  185. "outputs": [
  186. {
  187. "data": {
  188. "text/plain": [
  189. "[Row(activity=u'Clothing Sales', basket_amount=None, num_borrowers=1, male_proportion(borrowers)=u'0.0', disbursal_date=None, use=u'Compra de ropa dama, caballero y ni\\xf1o.', tags=[], status=u'deleted', delinquent=None),\n",
  190. " Row(activity=u'Food Production/Sales', basket_amount=None, num_borrowers=1, male_proportion(borrowers)=u'0.0', disbursal_date=u'2007-03-15T04:52:22Z', use=u'Working capital', tags=[], status=u'paid', delinquent=None),\n",
  191. " Row(activity=u'Food Production/Sales', basket_amount=None, num_borrowers=1, male_proportion(borrowers)=u'0.0', disbursal_date=u'2007-05-17T22:02:42Z', use=u'Sell bread at the local market', tags=[], status=u'paid', delinquent=None),\n",
  192. " Row(activity=u'Clothing Sales', basket_amount=None, num_borrowers=1, male_proportion(borrowers)=u'0.0', disbursal_date=u'2007-07-20T16:35:52Z', use=u'To buy more clothes and baby things for sale', tags=[], status=u'paid', delinquent=None),\n",
  193. " Row(activity=u'Livestock', basket_amount=None, num_borrowers=1, male_proportion(borrowers)=u'0.0', disbursal_date=u'2007-09-20T02:55:18Z', use=u'Lohoure Odio will use the loan to purchase pigs for meat sales', tags=[], status=u'paid', delinquent=None),\n",
  194. " Row(activity=u'Construction', basket_amount=None, num_borrowers=1, male_proportion(borrowers)=u'0.0', disbursal_date=u'2007-11-02T23:38:36Z', use=u'buy a welding machine', tags=[], status=u'paid', delinquent=None),\n",
  195. " Row(activity=u'Cereals', basket_amount=None, num_borrowers=1, male_proportion(borrowers)=u'0.0', disbursal_date=u'2007-12-13T18:22:55Z', use=u'To buy rice for resale', tags=[], status=u'paid', delinquent=None),\n",
  196. " Row(activity=u'Taxi', basket_amount=None, num_borrowers=1, male_proportion(borrowers)=u'1.0', disbursal_date=u'2008-01-11T20:44:52Z', use=u'Taxi repairs and repainting', tags=[], status=u'paid', delinquent=None),\n",
  197. " Row(activity=u'Used Clothing', basket_amount=None, num_borrowers=4, male_proportion(borrowers)=u'0.0', disbursal_date=u'2008-04-19T14:11:32Z', use=u'to invest in their businesses', tags=[], status=u'paid', delinquent=None),\n",
  198. " Row(activity=u'Home Products Sales', basket_amount=None, num_borrowers=1, male_proportion(borrowers)=u'0.0', disbursal_date=u'2008-03-10T22:53:27Z', use=u'Edith needs a loan of 1000 soles (3 soles = $1), which she will use to buy more kitchen appliances.', tags=[], status=u'paid', delinquent=None)]"
  199. ]
  200. },
  201. "execution_count": 13,
  202. "metadata": {},
  203. "output_type": "execute_result"
  204. }
  205. ],
  206. "source": [
  207. "loans.registerTempTable(\"loans\")\n",
  208. "\n",
  209. "def male_proportion(borrowers):\n",
  210. " num_males = 0\n",
  211. " for item in borrowers:\n",
  212. " if item.gender == 'M':\n",
  213. " num_males += 1\n",
  214. " \n",
  215. " return num_males/ float(len(borrowers))\n",
  216. "\n",
  217. "sql_ctx.registerFunction('male_proportion', male_proportion)\n",
  218. "\n",
  219. "bad_loans = sql_ctx.sql(\"\"\"\n",
  220. "SELECT \n",
  221. " activity, \n",
  222. " basket_amount,\n",
  223. " size(borrowers) as num_borrowers,\n",
  224. " male_proportion(borrowers),\n",
  225. " terms.disbursal_date,\n",
  226. " \n",
  227. " use,\n",
  228. " tags,\n",
  229. " status,\n",
  230. " delinquent\n",
  231. "FROM loans\n",
  232. "LIMIT 10\n",
  233. "\"\"\")\n",
  234. "\n",
  235. "bad_loans.collect()"
  236. ]
  237. },
  238. {
  239. "cell_type": "code",
  240. "execution_count": 36,
  241. "metadata": {
  242. "collapsed": false
  243. },
  244. "outputs": [
  245. {
  246. "data": {
  247. "text/plain": [
  248. "[Row(status=u'refunded', count(1)=5504),\n",
  249. " Row(status=u'defaulted', count(1)=21776),\n",
  250. " Row(status=u'in_repayment', count(1)=155748),\n",
  251. " Row(status=u'reviewed', count(1)=3),\n",
  252. " Row(status=u'deleted', count(1)=2722),\n",
  253. " Row(status=u'paid', count(1)=775330),\n",
  254. " Row(status=u'issue', count(1)=199),\n",
  255. " Row(status=u'inactive_expired', count(1)=12421),\n",
  256. " Row(status=u'fundraising', count(1)=3986),\n",
  257. " Row(status=u'expired', count(1)=33773)]"
  258. ]
  259. },
  260. "execution_count": 36,
  261. "metadata": {},
  262. "output_type": "execute_result"
  263. }
  264. ],
  265. "source": [
  266. "sql_ctx.sql(\"\"\"\n",
  267. "SELECT\n",
  268. " status,\n",
  269. " COUNT(*)\n",
  270. "FROM loans\n",
  271. "GROUP BY status\n",
  272. "LIMIT 10\n",
  273. "\"\"\").collect()"
  274. ]
  275. },
  276. {
  277. "cell_type": "markdown",
  278. "metadata": {},
  279. "source": [
  280. " "
  281. ]
  282. },
  283. {
  284. "cell_type": "markdown",
  285. "metadata": {},
  286. "source": [
  287. "# Starts Here - GDP"
  288. ]
  289. },
  290. {
  291. "cell_type": "markdown",
  292. "metadata": {},
  293. "source": [
  294. "### Datasets sources\n",
  295. "1. Country codes - https://github.com/datasets/country-codes/tree/master/data\n",
  296. "2. GDP Data - http://data.worldbank.org/indicator/NY.GDP.MKTP.CD"
  297. ]
  298. },
  299. {
  300. "cell_type": "code",
  301. "execution_count": 14,
  302. "metadata": {
  303. "collapsed": true
  304. },
  305. "outputs": [],
  306. "source": [
  307. "import pandas as pd\n",
  308. "from datetime import datetime\n",
  309. "import numpy as np\n",
  310. "import math\n",
  311. "\n",
  312. "\n",
  313. "# Load country info data\n",
  314. "country_codes_raw = pd.read_csv(LOCAL_PATH + 'economic-data/country-codes.csv')\n",
  315. "country_gdp_raw = pd.read_csv(LOCAL_PATH + 'economic-data/country-gdp.csv')"
  316. ]
  317. },
  318. {
  319. "cell_type": "code",
  320. "execution_count": 15,
  321. "metadata": {
  322. "collapsed": false
  323. },
  324. "outputs": [
  325. {
  326. "data": {
  327. "text/html": [
  328. "<div>\n",
  329. "<table border=\"1\" class=\"dataframe\">\n",
  330. " <thead>\n",
  331. " <tr style=\"text-align: right;\">\n",
  332. " <th></th>\n",
  333. " <th>name</th>\n",
  334. " <th>official_name_en</th>\n",
  335. " <th>official_name_fr</th>\n",
  336. " <th>ISO3166-1-Alpha-2</th>\n",
  337. " <th>ISO3166-1-Alpha-3</th>\n",
  338. " <th>ISO3166-1-numeric</th>\n",
  339. " <th>ITU</th>\n",
  340. " <th>MARC</th>\n",
  341. " <th>WMO</th>\n",
  342. " <th>DS</th>\n",
  343. " <th>...</th>\n",
  344. " <th>ISO4217-currency_minor_unit</th>\n",
  345. " <th>ISO4217-currency_name</th>\n",
  346. " <th>ISO4217-currency_numeric_code</th>\n",
  347. " <th>is_independent</th>\n",
  348. " <th>Capital</th>\n",
  349. " <th>Continent</th>\n",
  350. " <th>TLD</th>\n",
  351. " <th>Languages</th>\n",
  352. " <th>geonameid</th>\n",
  353. " <th>EDGAR</th>\n",
  354. " </tr>\n",
  355. " </thead>\n",
  356. " <tbody>\n",
  357. " <tr>\n",
  358. " <th>0</th>\n",
  359. " <td>NaN</td>\n",
  360. " <td>Channel Islands</td>\n",
  361. " <td>Îles Anglo-Normandes</td>\n",
  362. " <td>NaN</td>\n",
  363. " <td>NaN</td>\n",
  364. " <td>830</td>\n",
  365. " <td>NaN</td>\n",
  366. " <td>NaN</td>\n",
  367. " <td>NaN</td>\n",
  368. " <td>NaN</td>\n",
  369. " <td>...</td>\n",
  370. " <td>NaN</td>\n",
  371. " <td>NaN</td>\n",
  372. " <td>NaN</td>\n",
  373. " <td>NaN</td>\n",
  374. " <td>NaN</td>\n",
  375. " <td>NaN</td>\n",
  376. " <td>NaN</td>\n",
  377. " <td>NaN</td>\n",
  378. " <td>NaN</td>\n",
  379. " <td>NaN</td>\n",
  380. " </tr>\n",
  381. " <tr>\n",
  382. " <th>1</th>\n",
  383. " <td>NaN</td>\n",
  384. " <td>Sark</td>\n",
  385. " <td>Sercq</td>\n",
  386. " <td>NaN</td>\n",
  387. " <td>NaN</td>\n",
  388. " <td>680</td>\n",
  389. " <td>NaN</td>\n",
  390. " <td>NaN</td>\n",
  391. " <td>NaN</td>\n",
  392. " <td>NaN</td>\n",
  393. " <td>...</td>\n",
  394. " <td>NaN</td>\n",
  395. " <td>NaN</td>\n",
  396. " <td>NaN</td>\n",
  397. " <td>NaN</td>\n",
  398. " <td>NaN</td>\n",
  399. " <td>NaN</td>\n",
  400. " <td>NaN</td>\n",
  401. " <td>NaN</td>\n",
  402. " <td>NaN</td>\n",
  403. " <td>NaN</td>\n",
  404. " </tr>\n",
  405. " <tr>\n",
  406. " <th>2</th>\n",
  407. " <td>Afghanistan</td>\n",
  408. " <td>Afghanistan</td>\n",
  409. " <td>Afghanistan</td>\n",
  410. " <td>AF</td>\n",
  411. " <td>AFG</td>\n",
  412. " <td>4</td>\n",
  413. " <td>AFG</td>\n",
  414. " <td>af</td>\n",
  415. " <td>AF</td>\n",
  416. " <td>AFG</td>\n",
  417. " <td>...</td>\n",
  418. " <td>2.0</td>\n",
  419. " <td>Afghani</td>\n",
  420. " <td>971.0</td>\n",
  421. " <td>Yes</td>\n",
  422. " <td>Kabul</td>\n",
  423. " <td>AS</td>\n",
  424. " <td>.af</td>\n",
  425. " <td>fa-AF,ps,uz-AF,tk</td>\n",
  426. " <td>1149361.0</td>\n",
  427. " <td>B2</td>\n",
  428. " </tr>\n",
  429. " <tr>\n",
  430. " <th>3</th>\n",
  431. " <td>Albania</td>\n",
  432. " <td>Albania</td>\n",
  433. " <td>Albanie</td>\n",
  434. " <td>AL</td>\n",
  435. " <td>ALB</td>\n",
  436. " <td>8</td>\n",
  437. " <td>ALB</td>\n",
  438. " <td>aa</td>\n",
  439. " <td>AB</td>\n",
  440. " <td>AL</td>\n",
  441. " <td>...</td>\n",
  442. " <td>2.0</td>\n",
  443. " <td>Lek</td>\n",
  444. " <td>8.0</td>\n",
  445. " <td>Yes</td>\n",
  446. " <td>Tirana</td>\n",
  447. " <td>EU</td>\n",
  448. " <td>.al</td>\n",
  449. " <td>sq,el</td>\n",
  450. " <td>783754.0</td>\n",
  451. " <td>B3</td>\n",
  452. " </tr>\n",
  453. " <tr>\n",
  454. " <th>4</th>\n",
  455. " <td>Algeria</td>\n",
  456. " <td>Algeria</td>\n",
  457. " <td>Algérie</td>\n",
  458. " <td>DZ</td>\n",
  459. " <td>DZA</td>\n",
  460. " <td>12</td>\n",
  461. " <td>ALG</td>\n",
  462. " <td>ae</td>\n",
  463. " <td>AL</td>\n",
  464. " <td>DZ</td>\n",
  465. " <td>...</td>\n",
  466. " <td>2.0</td>\n",
  467. " <td>Algerian Dinar</td>\n",
  468. " <td>12.0</td>\n",
  469. " <td>Yes</td>\n",
  470. " <td>Algiers</td>\n",
  471. " <td>AF</td>\n",
  472. " <td>.dz</td>\n",
  473. " <td>ar-DZ</td>\n",
  474. " <td>2589581.0</td>\n",
  475. " <td>B4</td>\n",
  476. " </tr>\n",
  477. " </tbody>\n",
  478. "</table>\n",
  479. "<p>5 rows × 27 columns</p>\n",
  480. "</div>"
  481. ],
  482. "text/plain": [
  483. " name official_name_en official_name_fr ISO3166-1-Alpha-2 \\\n",
  484. "0 NaN Channel Islands Îles Anglo-Normandes NaN \n",
  485. "1 NaN Sark Sercq NaN \n",
  486. "2 Afghanistan Afghanistan Afghanistan AF \n",
  487. "3 Albania Albania Albanie AL \n",
  488. "4 Algeria Algeria Algérie DZ \n",
  489. "\n",
  490. " ISO3166-1-Alpha-3 ISO3166-1-numeric ITU MARC WMO DS ... \\\n",
  491. "0 NaN 830 NaN NaN NaN NaN ... \n",
  492. "1 NaN 680 NaN NaN NaN NaN ... \n",
  493. "2 AFG 4 AFG af AF AFG ... \n",
  494. "3 ALB 8 ALB aa AB AL ... \n",
  495. "4 DZA 12 ALG ae AL DZ ... \n",
  496. "\n",
  497. " ISO4217-currency_minor_unit ISO4217-currency_name \\\n",
  498. "0 NaN NaN \n",
  499. "1 NaN NaN \n",
  500. "2 2.0 Afghani \n",
  501. "3 2.0 Lek \n",
  502. "4 2.0 Algerian Dinar \n",
  503. "\n",
  504. " ISO4217-currency_numeric_code is_independent Capital Continent TLD \\\n",
  505. "0 NaN NaN NaN NaN NaN \n",
  506. "1 NaN NaN NaN NaN NaN \n",
  507. "2 971.0 Yes Kabul AS .af \n",
  508. "3 8.0 Yes Tirana EU .al \n",
  509. "4 12.0 Yes Algiers AF .dz \n",
  510. "\n",
  511. " Languages geonameid EDGAR \n",
  512. "0 NaN NaN NaN \n",
  513. "1 NaN NaN NaN \n",
  514. "2 fa-AF,ps,uz-AF,tk 1149361.0 B2 \n",
  515. "3 sq,el 783754.0 B3 \n",
  516. "4 ar-DZ 2589581.0 B4 \n",
  517. "\n",
  518. "[5 rows x 27 columns]"
  519. ]
  520. },
  521. "execution_count": 15,
  522. "metadata": {},
  523. "output_type": "execute_result"
  524. }
  525. ],
  526. "source": [
  527. "country_codes_raw.head()"
  528. ]
  529. },
  530. {
  531. "cell_type": "code",
  532. "execution_count": 16,
  533. "metadata": {
  534. "collapsed": false
  535. },
  536. "outputs": [
  537. {
  538. "data": {
  539. "text/html": [
  540. "<div>\n",
  541. "<table border=\"1\" class=\"dataframe\">\n",
  542. " <thead>\n",
  543. " <tr style=\"text-align: right;\">\n",
  544. " <th></th>\n",
  545. " <th>Series Name</th>\n",
  546. " <th>Series Code</th>\n",
  547. " <th>Country Name</th>\n",
  548. " <th>Country Code</th>\n",
  549. " <th>2002 [YR2002]</th>\n",
  550. " <th>2003 [YR2003]</th>\n",
  551. " <th>2004 [YR2004]</th>\n",
  552. " <th>2005 [YR2005]</th>\n",
  553. " <th>2006 [YR2006]</th>\n",
  554. " <th>2007 [YR2007]</th>\n",
  555. " <th>2008 [YR2008]</th>\n",
  556. " <th>2009 [YR2009]</th>\n",
  557. " <th>2010 [YR2010]</th>\n",
  558. " <th>2011 [YR2011]</th>\n",
  559. " <th>2012 [YR2012]</th>\n",
  560. " <th>2013 [YR2013]</th>\n",
  561. " <th>2014 [YR2014]</th>\n",
  562. " <th>2015 [YR2015]</th>\n",
  563. " <th>2016 [YR2016]</th>\n",
  564. " </tr>\n",
  565. " </thead>\n",
  566. " <tbody>\n",
  567. " <tr>\n",
  568. " <th>0</th>\n",
  569. " <td>GDP per capita (current US$)</td>\n",
  570. " <td>NY.GDP.PCAP.CD</td>\n",
  571. " <td>Afghanistan</td>\n",
  572. " <td>AFG</td>\n",
  573. " <td>192.153528278789</td>\n",
  574. " <td>203.651040923182</td>\n",
  575. " <td>224.914712193371</td>\n",
  576. " <td>257.175794656273</td>\n",
  577. " <td>280.245644106914</td>\n",
  578. " <td>380.400955186598</td>\n",
  579. " <td>384.131681276838</td>\n",
  580. " <td>458.955781585831</td>\n",
  581. " <td>569.940728793286</td>\n",
  582. " <td>622.379654358451</td>\n",
  583. " <td>690.842629014956</td>\n",
  584. " <td>653.347488111011</td>\n",
  585. " <td>633.947864294639</td>\n",
  586. " <td>590.269515382605</td>\n",
  587. " <td>..</td>\n",
  588. " </tr>\n",
  589. " <tr>\n",
  590. " <th>1</th>\n",
  591. " <td>GDP per capita (current US$)</td>\n",
  592. " <td>NY.GDP.PCAP.CD</td>\n",
  593. " <td>Albania</td>\n",
  594. " <td>ALB</td>\n",
  595. " <td>1453.64277660853</td>\n",
  596. " <td>1890.68155743544</td>\n",
  597. " <td>2416.5882350701</td>\n",
  598. " <td>2709.14293056201</td>\n",
  599. " <td>3005.0129033756</td>\n",
  600. " <td>3603.01368536638</td>\n",
  601. " <td>4370.53964653148</td>\n",
  602. " <td>4114.13654490945</td>\n",
  603. " <td>4094.35883191918</td>\n",
  604. " <td>4437.8119990258</td>\n",
  605. " <td>4247.83985201907</td>\n",
  606. " <td>4412.34557813421</td>\n",
  607. " <td>4588.64944014811</td>\n",
  608. " <td>3965.01680558488</td>\n",
  609. " <td>..</td>\n",
  610. " </tr>\n",
  611. " <tr>\n",
  612. " <th>2</th>\n",
  613. " <td>GDP per capita (current US$)</td>\n",
  614. " <td>NY.GDP.PCAP.CD</td>\n",
  615. " <td>Algeria</td>\n",
  616. " <td>DZA</td>\n",
  617. " <td>1774.29202079911</td>\n",
  618. " <td>2094.89330213298</td>\n",
  619. " <td>2600.00651972559</td>\n",
  620. " <td>3102.03738422673</td>\n",
  621. " <td>3467.54474008596</td>\n",
  622. " <td>3939.55993939808</td>\n",
  623. " <td>4912.25194081995</td>\n",
  624. " <td>3875.82209542426</td>\n",
  625. " <td>4473.48644568115</td>\n",
  626. " <td>5447.40397556569</td>\n",
  627. " <td>5583.61615950131</td>\n",
  628. " <td>5491.6144135648</td>\n",
  629. " <td>5484.0668056148</td>\n",
  630. " <td>4206.03123244958</td>\n",
  631. " <td>..</td>\n",
  632. " </tr>\n",
  633. " <tr>\n",
  634. " <th>3</th>\n",
  635. " <td>GDP per capita (current US$)</td>\n",
  636. " <td>NY.GDP.PCAP.CD</td>\n",
  637. " <td>American Samoa</td>\n",
  638. " <td>ASM</td>\n",
  639. " <td>..</td>\n",
  640. " <td>..</td>\n",
  641. " <td>..</td>\n",
  642. " <td>..</td>\n",
  643. " <td>..</td>\n",
  644. " <td>..</td>\n",
  645. " <td>..</td>\n",
  646. " <td>..</td>\n",
  647. " <td>..</td>\n",
  648. " <td>..</td>\n",
  649. " <td>..</td>\n",
  650. " <td>..</td>\n",
  651. " <td>..</td>\n",
  652. " <td>..</td>\n",
  653. " <td>..</td>\n",
  654. " </tr>\n",
  655. " <tr>\n",
  656. " <th>4</th>\n",
  657. " <td>GDP per capita (current US$)</td>\n",
  658. " <td>NY.GDP.PCAP.CD</td>\n",
  659. " <td>Andorra</td>\n",
  660. " <td>ADO</td>\n",
  661. " <td>24175.3727542522</td>\n",
  662. " <td>31742.9925847537</td>\n",
  663. " <td>37235.4500323146</td>\n",
  664. " <td>39990.3304085679</td>\n",
  665. " <td>42417.2291456984</td>\n",
  666. " <td>47253.5297963111</td>\n",
  667. " <td>46735.9995745016</td>\n",
  668. " <td>42701.447136255</td>\n",
  669. " <td>39639.386021211</td>\n",
  670. " <td>41630.0525792977</td>\n",
  671. " <td>39666.3692147448</td>\n",
  672. " <td>42806.5224483021</td>\n",
  673. " <td>..</td>\n",
  674. " <td>..</td>\n",
  675. " <td>..</td>\n",
  676. " </tr>\n",
  677. " </tbody>\n",
  678. "</table>\n",
  679. "</div>"
  680. ],
  681. "text/plain": [
  682. " Series Name Series Code Country Name Country Code \\\n",
  683. "0 GDP per capita (current US$) NY.GDP.PCAP.CD Afghanistan AFG \n",
  684. "1 GDP per capita (current US$) NY.GDP.PCAP.CD Albania ALB \n",
  685. "2 GDP per capita (current US$) NY.GDP.PCAP.CD Algeria DZA \n",
  686. "3 GDP per capita (current US$) NY.GDP.PCAP.CD American Samoa ASM \n",
  687. "4 GDP per capita (current US$) NY.GDP.PCAP.CD Andorra ADO \n",
  688. "\n",
  689. " 2002 [YR2002] 2003 [YR2003] 2004 [YR2004] 2005 [YR2005] \\\n",
  690. "0 192.153528278789 203.651040923182 224.914712193371 257.175794656273 \n",
  691. "1 1453.64277660853 1890.68155743544 2416.5882350701 2709.14293056201 \n",
  692. "2 1774.29202079911 2094.89330213298 2600.00651972559 3102.03738422673 \n",
  693. "3 .. .. .. .. \n",
  694. "4 24175.3727542522 31742.9925847537 37235.4500323146 39990.3304085679 \n",
  695. "\n",
  696. " 2006 [YR2006] 2007 [YR2007] 2008 [YR2008] 2009 [YR2009] \\\n",
  697. "0 280.245644106914 380.400955186598 384.131681276838 458.955781585831 \n",
  698. "1 3005.0129033756 3603.01368536638 4370.53964653148 4114.13654490945 \n",
  699. "2 3467.54474008596 3939.55993939808 4912.25194081995 3875.82209542426 \n",
  700. "3 .. .. .. .. \n",
  701. "4 42417.2291456984 47253.5297963111 46735.9995745016 42701.447136255 \n",
  702. "\n",
  703. " 2010 [YR2010] 2011 [YR2011] 2012 [YR2012] 2013 [YR2013] \\\n",
  704. "0 569.940728793286 622.379654358451 690.842629014956 653.347488111011 \n",
  705. "1 4094.35883191918 4437.8119990258 4247.83985201907 4412.34557813421 \n",
  706. "2 4473.48644568115 5447.40397556569 5583.61615950131 5491.6144135648 \n",
  707. "3 .. .. .. .. \n",
  708. "4 39639.386021211 41630.0525792977 39666.3692147448 42806.5224483021 \n",
  709. "\n",
  710. " 2014 [YR2014] 2015 [YR2015] 2016 [YR2016] \n",
  711. "0 633.947864294639 590.269515382605 .. \n",
  712. "1 4588.64944014811 3965.01680558488 .. \n",
  713. "2 5484.0668056148 4206.03123244958 .. \n",
  714. "3 .. .. .. \n",
  715. "4 .. .. .. "
  716. ]
  717. },
  718. "execution_count": 16,
  719. "metadata": {},
  720. "output_type": "execute_result"
  721. }
  722. ],
  723. "source": [
  724. "country_gdp_raw.head()"
  725. ]
  726. },
  727. {
  728. "cell_type": "code",
  729. "execution_count": 17,
  730. "metadata": {
  731. "collapsed": false
  732. },
  733. "outputs": [
  734. {
  735. "data": {
  736. "text/html": [
  737. "<div>\n",
  738. "<table border=\"1\" class=\"dataframe\">\n",
  739. " <thead>\n",
  740. " <tr style=\"text-align: right;\">\n",
  741. " <th></th>\n",
  742. " <th>official_name_en</th>\n",
  743. " <th>ISO3166-1-Alpha-2</th>\n",
  744. " <th>ISO3166-1-Alpha-3</th>\n",
  745. " <th>ISO4217-currency_alphabetic_code</th>\n",
  746. " </tr>\n",
  747. " </thead>\n",
  748. " <tbody>\n",
  749. " <tr>\n",
  750. " <th>0</th>\n",
  751. " <td>Channel Islands</td>\n",
  752. " <td>NaN</td>\n",
  753. " <td>NaN</td>\n",
  754. " <td>NaN</td>\n",
  755. " </tr>\n",
  756. " <tr>\n",
  757. " <th>1</th>\n",
  758. " <td>Sark</td>\n",
  759. " <td>NaN</td>\n",
  760. " <td>NaN</td>\n",
  761. " <td>NaN</td>\n",
  762. " </tr>\n",
  763. " <tr>\n",
  764. " <th>2</th>\n",
  765. " <td>Afghanistan</td>\n",
  766. " <td>AF</td>\n",
  767. " <td>AFG</td>\n",
  768. " <td>AFN</td>\n",
  769. " </tr>\n",
  770. " <tr>\n",
  771. " <th>3</th>\n",
  772. " <td>Albania</td>\n",
  773. " <td>AL</td>\n",
  774. " <td>ALB</td>\n",
  775. " <td>ALL</td>\n",
  776. " </tr>\n",
  777. " <tr>\n",
  778. " <th>4</th>\n",
  779. " <td>Algeria</td>\n",
  780. " <td>DZ</td>\n",
  781. " <td>DZA</td>\n",
  782. " <td>DZD</td>\n",
  783. " </tr>\n",
  784. " <tr>\n",
  785. " <th>5</th>\n",
  786. " <td>American Samoa</td>\n",
  787. " <td>AS</td>\n",
  788. " <td>ASM</td>\n",
  789. " <td>USD</td>\n",
  790. " </tr>\n",
  791. " <tr>\n",
  792. " <th>6</th>\n",
  793. " <td>Andorra</td>\n",
  794. " <td>AD</td>\n",
  795. " <td>AND</td>\n",
  796. " <td>EUR</td>\n",
  797. " </tr>\n",
  798. " <tr>\n",
  799. " <th>7</th>\n",
  800. " <td>Angola</td>\n",
  801. " <td>AO</td>\n",
  802. " <td>AGO</td>\n",
  803. " <td>AOA</td>\n",
  804. " </tr>\n",
  805. " <tr>\n",
  806. " <th>8</th>\n",
  807. " <td>Anguilla</td>\n",
  808. " <td>AI</td>\n",
  809. " <td>AIA</td>\n",
  810. " <td>XCD</td>\n",
  811. " </tr>\n",
  812. " <tr>\n",
  813. " <th>9</th>\n",
  814. " <td>NaN</td>\n",
  815. " <td>AQ</td>\n",
  816. " <td>ATA</td>\n",
  817. " <td>NaN</td>\n",
  818. " </tr>\n",
  819. " </tbody>\n",
  820. "</table>\n",
  821. "</div>"
  822. ],
  823. "text/plain": [
  824. " official_name_en ISO3166-1-Alpha-2 ISO3166-1-Alpha-3 \\\n",
  825. "0 Channel Islands NaN NaN \n",
  826. "1 Sark NaN NaN \n",
  827. "2 Afghanistan AF AFG \n",
  828. "3 Albania AL ALB \n",
  829. "4 Algeria DZ DZA \n",
  830. "5 American Samoa AS ASM \n",
  831. "6 Andorra AD AND \n",
  832. "7 Angola AO AGO \n",
  833. "8 Anguilla AI AIA \n",
  834. "9 NaN AQ ATA \n",
  835. "\n",
  836. " ISO4217-currency_alphabetic_code \n",
  837. "0 NaN \n",
  838. "1 NaN \n",
  839. "2 AFN \n",
  840. "3 ALL \n",
  841. "4 DZD \n",
  842. "5 USD \n",
  843. "6 EUR \n",
  844. "7 AOA \n",
  845. "8 XCD \n",
  846. "9 NaN "
  847. ]
  848. },
  849. "execution_count": 17,
  850. "metadata": {},
  851. "output_type": "execute_result"
  852. }
  853. ],
  854. "source": [
  855. "# Clean country codes data\n",
  856. "country_codes = country_codes_raw[['official_name_en', 'ISO3166-1-Alpha-2', 'ISO3166-1-Alpha-3', 'ISO4217-currency_alphabetic_code']]\n",
  857. "country_codes.head(10)"
  858. ]
  859. },
  860. {
  861. "cell_type": "code",
  862. "execution_count": 18,
  863. "metadata": {
  864. "collapsed": false
  865. },
  866. "outputs": [],
  867. "source": [
  868. "# Clean gdp data\n",
  869. "country_gdp = country_gdp_raw.drop(country_gdp_raw.columns[[0, 1]], axis=1)\n",
  870. "country_gdp.columns = ['name', 'country_code_3', '2002', '2003', '2004', '2005', '2006',\n",
  871. " '2007', '2008', '2009', '2010', '2011', '2012', '2013', '2014', '2015', '2016']"
  872. ]
  873. },
  874. {
  875. "cell_type": "code",
  876. "execution_count": 19,
  877. "metadata": {
  878. "collapsed": false
  879. },
  880. "outputs": [
  881. {
  882. "data": {
  883. "text/html": [
  884. "<div>\n",
  885. "<table border=\"1\" class=\"dataframe\">\n",
  886. " <thead>\n",
  887. " <tr style=\"text-align: right;\">\n",
  888. " <th></th>\n",
  889. " <th>name</th>\n",
  890. " <th>country_code_3</th>\n",
  891. " <th>2002</th>\n",
  892. " <th>2003</th>\n",
  893. " <th>2004</th>\n",
  894. " <th>2005</th>\n",
  895. " <th>2006</th>\n",
  896. " <th>2007</th>\n",
  897. " <th>2008</th>\n",
  898. " <th>2009</th>\n",
  899. " <th>2010</th>\n",
  900. " <th>2011</th>\n",
  901. " <th>2012</th>\n",
  902. " <th>2013</th>\n",
  903. " <th>2014</th>\n",
  904. " <th>2015</th>\n",
  905. " <th>2016</th>\n",
  906. " </tr>\n",
  907. " </thead>\n",
  908. " <tbody>\n",
  909. " <tr>\n",
  910. " <th>0</th>\n",
  911. " <td>Afghanistan</td>\n",
  912. " <td>AFG</td>\n",
  913. " <td>192.153528278789</td>\n",
  914. " <td>203.651040923182</td>\n",
  915. " <td>224.914712193371</td>\n",
  916. " <td>257.175794656273</td>\n",
  917. " <td>280.245644106914</td>\n",
  918. " <td>380.400955186598</td>\n",
  919. " <td>384.131681276838</td>\n",
  920. " <td>458.955781585831</td>\n",
  921. " <td>569.940728793286</td>\n",
  922. " <td>622.379654358451</td>\n",
  923. " <td>690.842629014956</td>\n",
  924. " <td>653.347488111011</td>\n",
  925. " <td>633.947864294639</td>\n",
  926. " <td>590.269515382605</td>\n",
  927. " <td>..</td>\n",
  928. " </tr>\n",
  929. " <tr>\n",
  930. " <th>1</th>\n",
  931. " <td>Albania</td>\n",
  932. " <td>ALB</td>\n",
  933. " <td>1453.64277660853</td>\n",
  934. " <td>1890.68155743544</td>\n",
  935. " <td>2416.5882350701</td>\n",
  936. " <td>2709.14293056201</td>\n",
  937. " <td>3005.0129033756</td>\n",
  938. " <td>3603.01368536638</td>\n",
  939. " <td>4370.53964653148</td>\n",
  940. " <td>4114.13654490945</td>\n",
  941. " <td>4094.35883191918</td>\n",
  942. " <td>4437.8119990258</td>\n",
  943. " <td>4247.83985201907</td>\n",
  944. " <td>4412.34557813421</td>\n",
  945. " <td>4588.64944014811</td>\n",
  946. " <td>3965.01680558488</td>\n",
  947. " <td>..</td>\n",
  948. " </tr>\n",
  949. " <tr>\n",
  950. " <th>2</th>\n",
  951. " <td>Algeria</td>\n",
  952. " <td>DZA</td>\n",
  953. " <td>1774.29202079911</td>\n",
  954. " <td>2094.89330213298</td>\n",
  955. " <td>2600.00651972559</td>\n",
  956. " <td>3102.03738422673</td>\n",
  957. " <td>3467.54474008596</td>\n",
  958. " <td>3939.55993939808</td>\n",
  959. " <td>4912.25194081995</td>\n",
  960. " <td>3875.82209542426</td>\n",
  961. " <td>4473.48644568115</td>\n",
  962. " <td>5447.40397556569</td>\n",
  963. " <td>5583.61615950131</td>\n",
  964. " <td>5491.6144135648</td>\n",
  965. " <td>5484.0668056148</td>\n",
  966. " <td>4206.03123244958</td>\n",
  967. " <td>..</td>\n",
  968. " </tr>\n",
  969. " <tr>\n",
  970. " <th>3</th>\n",
  971. " <td>American Samoa</td>\n",
  972. " <td>ASM</td>\n",
  973. " <td>..</td>\n",
  974. " <td>..</td>\n",
  975. " <td>..</td>\n",
  976. " <td>..</td>\n",
  977. " <td>..</td>\n",
  978. " <td>..</td>\n",
  979. " <td>..</td>\n",
  980. " <td>..</td>\n",
  981. " <td>..</td>\n",
  982. " <td>..</td>\n",
  983. " <td>..</td>\n",
  984. " <td>..</td>\n",
  985. " <td>..</td>\n",
  986. " <td>..</td>\n",
  987. " <td>..</td>\n",
  988. " </tr>\n",
  989. " <tr>\n",
  990. " <th>4</th>\n",
  991. " <td>Andorra</td>\n",
  992. " <td>ADO</td>\n",
  993. " <td>24175.3727542522</td>\n",
  994. " <td>31742.9925847537</td>\n",
  995. " <td>37235.4500323146</td>\n",
  996. " <td>39990.3304085679</td>\n",
  997. " <td>42417.2291456984</td>\n",
  998. " <td>47253.5297963111</td>\n",
  999. " <td>46735.9995745016</td>\n",
  1000. " <td>42701.447136255</td>\n",
  1001. " <td>39639.386021211</td>\n",
  1002. " <td>41630.0525792977</td>\n",
  1003. " <td>39666.3692147448</td>\n",
  1004. " <td>42806.5224483021</td>\n",
  1005. " <td>..</td>\n",
  1006. " <td>..</td>\n",
  1007. " <td>..</td>\n",
  1008. " </tr>\n",
  1009. " </tbody>\n",
  1010. "</table>\n",
  1011. "</div>"
  1012. ],
  1013. "text/plain": [
  1014. " name country_code_3 2002 2003 \\\n",
  1015. "0 Afghanistan AFG 192.153528278789 203.651040923182 \n",
  1016. "1 Albania ALB 1453.64277660853 1890.68155743544 \n",
  1017. "2 Algeria DZA 1774.29202079911 2094.89330213298 \n",
  1018. "3 American Samoa ASM .. .. \n",
  1019. "4 Andorra ADO 24175.3727542522 31742.9925847537 \n",
  1020. "\n",
  1021. " 2004 2005 2006 2007 \\\n",
  1022. "0 224.914712193371 257.175794656273 280.245644106914 380.400955186598 \n",
  1023. "1 2416.5882350701 2709.14293056201 3005.0129033756 3603.01368536638 \n",
  1024. "2 2600.00651972559 3102.03738422673 3467.54474008596 3939.55993939808 \n",
  1025. "3 .. .. .. .. \n",
  1026. "4 37235.4500323146 39990.3304085679 42417.2291456984 47253.5297963111 \n",
  1027. "\n",
  1028. " 2008 2009 2010 2011 \\\n",
  1029. "0 384.131681276838 458.955781585831 569.940728793286 622.379654358451 \n",
  1030. "1 4370.53964653148 4114.13654490945 4094.35883191918 4437.8119990258 \n",
  1031. "2 4912.25194081995 3875.82209542426 4473.48644568115 5447.40397556569 \n",
  1032. "3 .. .. .. .. \n",
  1033. "4 46735.9995745016 42701.447136255 39639.386021211 41630.0525792977 \n",
  1034. "\n",
  1035. " 2012 2013 2014 2015 2016 \n",
  1036. "0 690.842629014956 653.347488111011 633.947864294639 590.269515382605 .. \n",
  1037. "1 4247.83985201907 4412.34557813421 4588.64944014811 3965.01680558488 .. \n",
  1038. "2 5583.61615950131 5491.6144135648 5484.0668056148 4206.03123244958 .. \n",
  1039. "3 .. .. .. .. .. \n",
  1040. "4 39666.3692147448 42806.5224483021 .. .. .. "
  1041. ]
  1042. },
  1043. "execution_count": 19,
  1044. "metadata": {},
  1045. "output_type": "execute_result"
  1046. }
  1047. ],
  1048. "source": [
  1049. "country_gdp.head()"
  1050. ]
  1051. },
  1052. {
  1053. "cell_type": "code",
  1054. "execution_count": 20,
  1055. "metadata": {
  1056. "collapsed": false
  1057. },
  1058. "outputs": [
  1059. {
  1060. "data": {
  1061. "text/html": [
  1062. "<div>\n",
  1063. "<table border=\"1\" class=\"dataframe\">\n",
  1064. " <thead>\n",
  1065. " <tr style=\"text-align: right;\">\n",
  1066. " <th></th>\n",
  1067. " <th>name</th>\n",
  1068. " <th>country_code</th>\n",
  1069. " <th>currency_code</th>\n",
  1070. " <th>2002</th>\n",
  1071. " <th>2003</th>\n",
  1072. " <th>2004</th>\n",
  1073. " <th>2005</th>\n",
  1074. " <th>2006</th>\n",
  1075. " <th>2007</th>\n",
  1076. " <th>2008</th>\n",
  1077. " <th>2009</th>\n",
  1078. " <th>2010</th>\n",
  1079. " <th>2011</th>\n",
  1080. " <th>2012</th>\n",
  1081. " <th>2013</th>\n",
  1082. " <th>2014</th>\n",
  1083. " <th>2015</th>\n",
  1084. " <th>2016</th>\n",
  1085. " </tr>\n",
  1086. " </thead>\n",
  1087. " <tbody>\n",
  1088. " <tr>\n",
  1089. " <th>0</th>\n",
  1090. " <td>Afghanistan</td>\n",
  1091. " <td>AF</td>\n",
  1092. " <td>AFN</td>\n",
  1093. " <td>192.153528278789</td>\n",
  1094. " <td>203.651040923182</td>\n",
  1095. " <td>224.914712193371</td>\n",
  1096. " <td>257.175794656273</td>\n",
  1097. " <td>280.245644106914</td>\n",
  1098. " <td>380.400955186598</td>\n",
  1099. " <td>384.131681276838</td>\n",
  1100. " <td>458.955781585831</td>\n",
  1101. " <td>569.940728793286</td>\n",
  1102. " <td>622.379654358451</td>\n",
  1103. " <td>690.842629014956</td>\n",
  1104. " <td>653.347488111011</td>\n",
  1105. " <td>633.947864294639</td>\n",
  1106. " <td>590.269515382605</td>\n",
  1107. " <td>NaN</td>\n",
  1108. " </tr>\n",
  1109. " <tr>\n",
  1110. " <th>1</th>\n",
  1111. " <td>Albania</td>\n",
  1112. " <td>AL</td>\n",
  1113. " <td>ALL</td>\n",
  1114. " <td>1453.64277660853</td>\n",
  1115. " <td>1890.68155743544</td>\n",
  1116. " <td>2416.5882350701</td>\n",
  1117. " <td>2709.14293056201</td>\n",
  1118. " <td>3005.0129033756</td>\n",
  1119. " <td>3603.01368536638</td>\n",
  1120. " <td>4370.53964653148</td>\n",
  1121. " <td>4114.13654490945</td>\n",
  1122. " <td>4094.35883191918</td>\n",
  1123. " <td>4437.8119990258</td>\n",
  1124. " <td>4247.83985201907</td>\n",
  1125. " <td>4412.34557813421</td>\n",
  1126. " <td>4588.64944014811</td>\n",
  1127. " <td>3965.01680558488</td>\n",
  1128. " <td>NaN</td>\n",
  1129. " </tr>\n",
  1130. " <tr>\n",
  1131. " <th>2</th>\n",
  1132. " <td>Algeria</td>\n",
  1133. " <td>DZ</td>\n",
  1134. " <td>DZD</td>\n",
  1135. " <td>1774.29202079911</td>\n",
  1136. " <td>2094.89330213298</td>\n",
  1137. " <td>2600.00651972559</td>\n",
  1138. " <td>3102.03738422673</td>\n",
  1139. " <td>3467.54474008596</td>\n",
  1140. " <td>3939.55993939808</td>\n",
  1141. " <td>4912.25194081995</td>\n",
  1142. " <td>3875.82209542426</td>\n",
  1143. " <td>4473.48644568115</td>\n",
  1144. " <td>5447.40397556569</td>\n",
  1145. " <td>5583.61615950131</td>\n",
  1146. " <td>5491.6144135648</td>\n",
  1147. " <td>5484.0668056148</td>\n",
  1148. " <td>4206.03123244958</td>\n",
  1149. " <td>NaN</td>\n",
  1150. " </tr>\n",
  1151. " <tr>\n",
  1152. " <th>3</th>\n",
  1153. " <td>American Samoa</td>\n",
  1154. " <td>AS</td>\n",
  1155. " <td>USD</td>\n",
  1156. " <td>NaN</td>\n",
  1157. " <td>NaN</td>\n",
  1158. " <td>NaN</td>\n",
  1159. " <td>NaN</td>\n",
  1160. " <td>NaN</td>\n",
  1161. " <td>NaN</td>\n",
  1162. " <td>NaN</td>\n",
  1163. " <td>NaN</td>\n",
  1164. " <td>NaN</td>\n",
  1165. " <td>NaN</td>\n",
  1166. " <td>NaN</td>\n",
  1167. " <td>NaN</td>\n",
  1168. " <td>NaN</td>\n",
  1169. " <td>NaN</td>\n",
  1170. " <td>NaN</td>\n",
  1171. " </tr>\n",
  1172. " <tr>\n",
  1173. " <th>4</th>\n",
  1174. " <td>Andorra</td>\n",
  1175. " <td>NaN</td>\n",
  1176. " <td>NaN</td>\n",
  1177. " <td>24175.3727542522</td>\n",
  1178. " <td>31742.9925847537</td>\n",
  1179. " <td>37235.4500323146</td>\n",
  1180. " <td>39990.3304085679</td>\n",
  1181. " <td>42417.2291456984</td>\n",
  1182. " <td>47253.5297963111</td>\n",
  1183. " <td>46735.9995745016</td>\n",
  1184. " <td>42701.447136255</td>\n",
  1185. " <td>39639.386021211</td>\n",
  1186. " <td>41630.0525792977</td>\n",
  1187. " <td>39666.3692147448</td>\n",
  1188. " <td>42806.5224483021</td>\n",
  1189. " <td>NaN</td>\n",
  1190. " <td>NaN</td>\n",
  1191. " <td>NaN</td>\n",
  1192. " </tr>\n",
  1193. " <tr>\n",
  1194. " <th>5</th>\n",
  1195. " <td>Angola</td>\n",
  1196. " <td>AO</td>\n",
  1197. " <td>AOA</td>\n",
  1198. " <td>775.765518459716</td>\n",
  1199. " <td>850.075694129697</td>\n",
  1200. " <td>1135.60456355085</td>\n",
  1201. " <td>1576.16280066689</td>\n",
  1202. " <td>2253.83885003865</td>\n",
  1203. " <td>3151.02243105289</td>\n",
  1204. " <td>4242.36306234092</td>\n",
  1205. " <td>3678.94765447179</td>\n",
  1206. " <td>3886.47935432524</td>\n",
  1207. " <td>4744.98762949589</td>\n",
  1208. " <td>5086.8484258086</td>\n",
  1209. " <td>5327.14889219232</td>\n",
  1210. " <td>5232.69050054132</td>\n",
  1211. " <td>4102.11858969272</td>\n",
  1212. " <td>NaN</td>\n",
  1213. " </tr>\n",
  1214. " <tr>\n",
  1215. " <th>6</th>\n",
  1216. " <td>Antigua and Barbuda</td>\n",
  1217. " <td>AG</td>\n",
  1218. " <td>XCD</td>\n",
  1219. " <td>10027.8562205839</td>\n",
  1220. " <td>10382.6309004545</td>\n",
  1221. " <td>10993.3692472668</td>\n",
  1222. " <td>12079.8656950416</td>\n",
  1223. " <td>13599.908857304</td>\n",
  1224. " <td>15276.0682646698</td>\n",
  1225. " <td>15786.1728395062</td>\n",
  1226. " <td>13979.2626925883</td>\n",
  1227. " <td>13017.3103875487</td>\n",
  1228. " <td>12817.8415733094</td>\n",
  1229. " <td>13525.616220134</td>\n",
  1230. " <td>13342.0849977054</td>\n",
  1231. " <td>13432.0792079208</td>\n",
  1232. " <td>14128.8785463675</td>\n",
  1233. " <td>NaN</td>\n",
  1234. " </tr>\n",
  1235. " <tr>\n",
  1236. " <th>7</th>\n",
  1237. " <td>Argentina</td>\n",
  1238. " <td>AR</td>\n",
  1239. " <td>ARS</td>\n",
  1240. " <td>2579.18819898884</td>\n",
  1241. " <td>3330.42866006847</td>\n",
  1242. " <td>4251.5653466058</td>\n",
  1243. " <td>5096.25833247505</td>\n",
  1244. " <td>5904.67813228342</td>\n",
  1245. " <td>7226.27029452745</td>\n",
  1246. " <td>8992.58961919674</td>\n",
  1247. " <td>8198.56611136286</td>\n",
  1248. " <td>10332.0323662966</td>\n",
  1249. " <td>12800.2018563295</td>\n",
  1250. " <td>13040.306395228</td>\n",
  1251. " <td>13027.2048221392</td>\n",
  1252. " <td>12324.9387857728</td>\n",
  1253. " <td>13431.8783398577</td>\n",
  1254. " <td>NaN</td>\n",
  1255. " </tr>\n",
  1256. " <tr>\n",
  1257. " <th>8</th>\n",
  1258. " <td>Armenia</td>\n",
  1259. " <td>AM</td>\n",
  1260. " <td>AMD</td>\n",
  1261. " <td>779.829626131555</td>\n",
  1262. " <td>924.464009817761</td>\n",
  1263. " <td>1181.9684454224</td>\n",
  1264. " <td>1625.40776912682</td>\n",
  1265. " <td>2126.61866107184</td>\n",
  1266. " <td>3080.97095943572</td>\n",
  1267. " <td>3919.97547381061</td>\n",
  1268. " <td>2915.5839059087</td>\n",
  1269. " <td>3124.78401786195</td>\n",
  1270. " <td>3417.17183599915</td>\n",
  1271. " <td>3565.5175749254</td>\n",
  1272. " <td>3716.82892254464</td>\n",
  1273. " <td>3873.53356580682</td>\n",
  1274. " <td>3499.80421759862</td>\n",
  1275. " <td>NaN</td>\n",
  1276. " </tr>\n",
  1277. " <tr>\n",
  1278. " <th>9</th>\n",
  1279. " <td>Aruba</td>\n",
  1280. " <td>AW</td>\n",
  1281. " <td>AWG</td>\n",
  1282. " <td>20433.6541088167</td>\n",
  1283. " <td>20834.9397101237</td>\n",
  1284. " <td>22566.6821576324</td>\n",
  1285. " <td>23302.8319880055</td>\n",
  1286. " <td>24015.4206122701</td>\n",
  1287. " <td>25921.5382341406</td>\n",
  1288. " <td>27549.8894224976</td>\n",
  1289. " <td>24640.4212441218</td>\n",
  1290. " <td>24289.1415161326</td>\n",
  1291. " <td>25353.7875446441</td>\n",
  1292. " <td>NaN</td>\n",
  1293. " <td>NaN</td>\n",
  1294. " <td>NaN</td>\n",
  1295. " <td>NaN</td>\n",
  1296. " <td>NaN</td>\n",
  1297. " </tr>\n",
  1298. " <tr>\n",
  1299. " <th>10</th>\n",
  1300. " <td>Australia</td>\n",
  1301. " <td>AU</td>\n",
  1302. " <td>AUD</td>\n",
  1303. " <td>20059.4520721372</td>\n",
  1304. " <td>23440.0053221856</td>\n",
  1305. " <td>30440.8548786229</td>\n",
  1306. " <td>33982.9504271591</td>\n",
  1307. " <td>36084.8589777475</td>\n",
  1308. " <td>40957.8304392487</td>\n",
  1309. " <td>49628.1151270179</td>\n",
  1310. " <td>42715.1322619629</td>\n",
  1311. " <td>51845.6548605562</td>\n",
  1312. " <td>62216.5471294133</td>\n",
  1313. " <td>67646.1038529626</td>\n",
  1314. " <td>67652.6832146189</td>\n",
  1315. " <td>61995.8296976</td>\n",
  1316. " <td>56327.7214484289</td>\n",
  1317. " <td>NaN</td>\n",
  1318. " </tr>\n",
  1319. " <tr>\n",
  1320. " <th>11</th>\n",
  1321. " <td>Austria</td>\n",
  1322. " <td>AT</td>\n",
  1323. " <td>EUR</td>\n",
  1324. " <td>26351.3756769542</td>\n",
  1325. " <td>32102.9305523558</td>\n",
  1326. " <td>36693.4026205182</td>\n",
  1327. " <td>38242.0425174699</td>\n",
  1328. " <td>40430.993614499</td>\n",
  1329. " <td>46586.6502529235</td>\n",
  1330. " <td>51386.3766511975</td>\n",
  1331. " <td>47654.1872090808</td>\n",
  1332. " <td>46659.8408181344</td>\n",
  1333. " <td>51123.5613291663</td>\n",
  1334. " <td>48324.2540367606</td>\n",
  1335. " <td>50557.8038059874</td>\n",
  1336. " <td>51148.3588760796</td>\n",
  1337. " <td>43438.8630381343</td>\n",
  1338. " <td>NaN</td>\n",
  1339. " </tr>\n",
  1340. " <tr>\n",
  1341. " <th>12</th>\n",
  1342. " <td>Azerbaijan</td>\n",
  1343. " <td>AZ</td>\n",
  1344. " <td>AZN</td>\n",
  1345. " <td>763.101212220367</td>\n",
  1346. " <td>883.614008967961</td>\n",
  1347. " <td>1045.02641527642</td>\n",
  1348. " <td>1578.36733030667</td>\n",
  1349. " <td>2473.08577636837</td>\n",
  1350. " <td>3851.43786871172</td>\n",
  1351. " <td>5574.60380218613</td>\n",
  1352. " <td>4950.29479142375</td>\n",
  1353. " <td>5842.80578358576</td>\n",
  1354. " <td>7189.69122920765</td>\n",
  1355. " <td>7393.77187697623</td>\n",
  1356. " <td>7811.6214184582</td>\n",
  1357. " <td>7886.45914367274</td>\n",
  1358. " <td>5496.34464026248</td>\n",
  1359. " <td>NaN</td>\n",
  1360. " </tr>\n",
  1361. " <tr>\n",
  1362. " <th>13</th>\n",
  1363. " <td>Bahamas, The</td>\n",
  1364. " <td>BS</td>\n",
  1365. " <td>BSD</td>\n",
  1366. " <td>22505.4047934793</td>\n",
  1367. " <td>22008.4337005989</td>\n",
  1368. " <td>21995.5199216219</td>\n",
  1369. " <td>23405.8795479327</td>\n",
  1370. " <td>23721.1562800587</td>\n",
  1371. " <td>24306.1424243044</td>\n",
  1372. " <td>23657.365306222</td>\n",
  1373. " <td>22043.0125711709</td>\n",
  1374. " <td>21920.5165867583</td>\n",
  1375. " <td>21514.8986531628</td>\n",
  1376. " <td>22112.6083547268</td>\n",
  1377. " <td>22315.6036533886</td>\n",
  1378. " <td>22217.4941392075</td>\n",
  1379. " <td>22896.9236868716</td>\n",
  1380. " <td>NaN</td>\n",
  1381. " </tr>\n",
  1382. " <tr>\n",
  1383. " <th>14</th>\n",
  1384. " <td>Bahrain</td>\n",
  1385. " <td>BH</td>\n",
  1386. " <td>BHD</td>\n",
  1387. " <td>13279.0457951397</td>\n",
  1388. " <td>14541.6160485141</td>\n",
  1389. " <td>16275.1804236433</td>\n",
  1390. " <td>18418.0726743768</td>\n",
  1391. " <td>19669.3195545631</td>\n",
  1392. " <td>21167.6187062133</td>\n",
  1393. " <td>23043.0253174017</td>\n",
  1394. " <td>19166.7082382358</td>\n",
  1395. " <td>20386.0175551116</td>\n",
  1396. " <td>22238.7119502059</td>\n",
  1397. " <td>23063.1322870426</td>\n",
  1398. " <td>24378.9448284188</td>\n",
  1399. " <td>24855.2156350086</td>\n",
  1400. " <td>23395.7476902684</td>\n",
  1401. " <td>NaN</td>\n",
  1402. " </tr>\n",
  1403. " <tr>\n",
  1404. " <th>15</th>\n",
  1405. " <td>Bangladesh</td>\n",
  1406. " <td>BD</td>\n",
  1407. " <td>BDT</td>\n",
  1408. " <td>401.708153328187</td>\n",
  1409. " <td>434.046563233432</td>\n",
  1410. " <td>462.274879844841</td>\n",
  1411. " <td>485.852888073473</td>\n",
  1412. " <td>495.853780201055</td>\n",
  1413. " <td>543.082263122362</td>\n",
  1414. " <td>618.075883559283</td>\n",
  1415. " <td>683.614422272329</td>\n",
  1416. " <td>760.331935200195</td>\n",
  1417. " <td>838.547801702232</td>\n",
  1418. " <td>858.933362587621</td>\n",
  1419. " <td>954.396399715624</td>\n",
  1420. " <td>1086.80008676935</td>\n",
  1421. " <td>1211.70153057661</td>\n",
  1422. " <td>NaN</td>\n",
  1423. " </tr>\n",
  1424. " <tr>\n",
  1425. " <th>16</th>\n",
  1426. " <td>Barbados</td>\n",
  1427. " <td>BB</td>\n",
  1428. " <td>BBD</td>\n",
  1429. " <td>11674.9361829092</td>\n",
  1430. " <td>12028.8987405468</td>\n",
  1431. " <td>12869.3365947615</td>\n",
  1432. " <td>14223.7777039775</td>\n",
  1433. " <td>15646.815008726</td>\n",
  1434. " <td>16461.8292691759</td>\n",
  1435. " <td>16569.6049618665</td>\n",
  1436. " <td>16526.2545517227</td>\n",
  1437. " <td>15901.4329353355</td>\n",
  1438. " <td>15530.8942915589</td>\n",
  1439. " <td>15317.1390013495</td>\n",
  1440. " <td>15153.8213753482</td>\n",
  1441. " <td>15366.2926106288</td>\n",
  1442. " <td>15660.6794152314</td>\n",
  1443. " <td>NaN</td>\n",
  1444. " </tr>\n",
  1445. " <tr>\n",
  1446. " <th>17</th>\n",
  1447. " <td>Belarus</td>\n",
  1448. " <td>BY</td>\n",
  1449. " <td>BYR</td>\n",
  1450. " <td>1479.46532113219</td>\n",
  1451. " <td>1819.4790277163</td>\n",
  1452. " <td>2378.37489391196</td>\n",
  1453. " <td>3126.36777779462</td>\n",
  1454. " <td>3848.58620300891</td>\n",
  1455. " <td>4735.95688918873</td>\n",
  1456. " <td>6376.17311491284</td>\n",
  1457. " <td>5176.04470138203</td>\n",
  1458. " <td>5818.8548592158</td>\n",
  1459. " <td>6305.77366247653</td>\n",
  1460. " <td>6721.83490773968</td>\n",
  1461. " <td>7722.12335060436</td>\n",
  1462. " <td>8025.30435552468</td>\n",
  1463. " <td>5740.45649479562</td>\n",
  1464. " <td>NaN</td>\n",
  1465. " </tr>\n",
  1466. " <tr>\n",
  1467. " <th>18</th>\n",
  1468. " <td>Belgium</td>\n",
  1469. " <td>BE</td>\n",
  1470. " <td>EUR</td>\n",
  1471. " <td>25052.3302823</td>\n",
  1472. " <td>30743.9569254283</td>\n",
  1473. " <td>35589.7129457001</td>\n",
  1474. " <td>36967.2829204297</td>\n",
  1475. " <td>38852.3610339939</td>\n",
  1476. " <td>44403.8313061102</td>\n",
  1477. " <td>48424.5892730273</td>\n",
  1478. " <td>44880.5601517887</td>\n",
  1479. " <td>44382.8797683492</td>\n",
  1480. " <td>47699.8070518961</td>\n",
  1481. " <td>44734.4523465803</td>\n",
  1482. " <td>46622.4679873931</td>\n",
  1483. " <td>47299.8601085612</td>\n",
  1484. " <td>40231.2831740081</td>\n",
  1485. " <td>NaN</td>\n",
  1486. " </tr>\n",
  1487. " <tr>\n",
  1488. " <th>19</th>\n",
  1489. " <td>Belize</td>\n",
  1490. " <td>BZ</td>\n",
  1491. " <td>BZD</td>\n",
  1492. " <td>3556.61608225719</td>\n",
  1493. " <td>3679.79281542143</td>\n",
  1494. " <td>3831.60983030588</td>\n",
  1495. " <td>3933.2343731798</td>\n",
  1496. " <td>4187.23288999866</td>\n",
  1497. " <td>4324.83101711444</td>\n",
  1498. " <td>4470.22079597603</td>\n",
  1499. " <td>4258.84287648324</td>\n",
  1500. " <td>4344.13666906088</td>\n",
  1501. " <td>4516.23303047149</td>\n",
  1502. " <td>4673.55519784264</td>\n",
  1503. " <td>4723.59432062825</td>\n",
  1504. " <td>4884.3686203818</td>\n",
  1505. " <td>4906.9406908683</td>\n",
  1506. " <td>NaN</td>\n",
  1507. " </tr>\n",
  1508. " <tr>\n",
  1509. " <th>20</th>\n",
  1510. " <td>Benin</td>\n",
  1511. " <td>BJ</td>\n",
  1512. " <td>XOF</td>\n",
  1513. " <td>411.959075281789</td>\n",
  1514. " <td>509.461088697817</td>\n",
  1515. " <td>570.685501333771</td>\n",
  1516. " <td>587.080212422838</td>\n",
  1517. " <td>609.018608681583</td>\n",
  1518. " <td>685.551675107742</td>\n",
  1519. " <td>794.870176064085</td>\n",
  1520. " <td>768.013476447657</td>\n",
  1521. " <td>732.953622726674</td>\n",
  1522. " <td>799.03555913143</td>\n",
  1523. " <td>807.688451017232</td>\n",
  1524. " <td>882.638633279988</td>\n",
  1525. " <td>903.464924007693</td>\n",
  1526. " <td>779.067867757338</td>\n",
  1527. " <td>NaN</td>\n",
  1528. " </tr>\n",
  1529. " <tr>\n",
  1530. " <th>21</th>\n",
  1531. " <td>Bermuda</td>\n",
  1532. " <td>BM</td>\n",
  1533. " <td>BMD</td>\n",
  1534. " <td>62583.1002034588</td>\n",
  1535. " <td>66111.7252270036</td>\n",
  1536. " <td>70359.3191088798</td>\n",
  1537. " <td>75882.0338560339</td>\n",
  1538. " <td>83912.6977976846</td>\n",
  1539. " <td>90849.5869806436</td>\n",
  1540. " <td>93605.7481653976</td>\n",
  1541. " <td>88463.3128161375</td>\n",
  1542. " <td>88207.3275597322</td>\n",
  1543. " <td>85973.158416455</td>\n",
  1544. " <td>85458.455507886</td>\n",
  1545. " <td>85748.0654143782</td>\n",
  1546. " <td>NaN</td>\n",
  1547. " <td>NaN</td>\n",
  1548. " <td>NaN</td>\n",
  1549. " </tr>\n",
  1550. " <tr>\n",
  1551. " <th>22</th>\n",
  1552. " <td>Bhutan</td>\n",
  1553. " <td>BT</td>\n",
  1554. " <td>INR</td>\n",
  1555. " <td>897.445333164014</td>\n",
  1556. " <td>1009.00623184688</td>\n",
  1557. " <td>1107.92059564068</td>\n",
  1558. " <td>1257.54864008661</td>\n",
  1559. " <td>1346.08577480046</td>\n",
  1560. " <td>1755.16170904287</td>\n",
  1561. " <td>1810.57617704401</td>\n",
  1562. " <td>1786.81067200588</td>\n",
  1563. " <td>2201.29307778936</td>\n",
  1564. " <td>2485.78705216849</td>\n",
  1565. " <td>2452.15158793741</td>\n",
  1566. " <td>2383.04472990264</td>\n",
  1567. " <td>2560.52213174131</td>\n",
  1568. " <td>2532.45446832741</td>\n",
  1569. " <td>NaN</td>\n",
  1570. " </tr>\n",
  1571. " <tr>\n",
  1572. " <th>23</th>\n",
  1573. " <td>Bolivia</td>\n",
  1574. " <td>BO</td>\n",
  1575. " <td>BOB</td>\n",
  1576. " <td>913.575853422027</td>\n",
  1577. " <td>917.36431048617</td>\n",
  1578. " <td>978.334757576746</td>\n",
  1579. " <td>1046.4278428307</td>\n",
  1580. " <td>1233.59297372996</td>\n",
  1581. " <td>1389.6317502607</td>\n",
  1582. " <td>1736.92401415151</td>\n",
  1583. " <td>1776.85718962366</td>\n",
  1584. " <td>1981.16010525701</td>\n",
  1585. " <td>2377.70068972888</td>\n",
  1586. " <td>2645.29027433174</td>\n",
  1587. " <td>2948.03291763073</td>\n",
  1588. " <td>3124.08076212353</td>\n",
  1589. " <td>3095.3596925636</td>\n",
  1590. " <td>NaN</td>\n",
  1591. " </tr>\n",
  1592. " <tr>\n",
  1593. " <th>24</th>\n",
  1594. " <td>Bosnia and Herzegovina</td>\n",
  1595. " <td>BA</td>\n",
  1596. " <td>BAM</td>\n",
  1597. " <td>1746.48638346723</td>\n",
  1598. " <td>2192.64707824367</td>\n",
  1599. " <td>2619.75325753727</td>\n",
  1600. " <td>2928.26359035282</td>\n",
  1601. " <td>3351.96339986152</td>\n",
  1602. " <td>4107.99623197216</td>\n",
  1603. " <td>4974.66226666137</td>\n",
  1604. " <td>4586.20631315947</td>\n",
  1605. " <td>4475.08813004565</td>\n",
  1606. " <td>4860.78181134244</td>\n",
  1607. " <td>4494.64064038047</td>\n",
  1608. " <td>4748.04069226421</td>\n",
  1609. " <td>4851.66052786926</td>\n",
  1610. " <td>4197.80730449044</td>\n",
  1611. " <td>NaN</td>\n",
  1612. " </tr>\n",
  1613. " <tr>\n",
  1614. " <th>25</th>\n",
  1615. " <td>Botswana</td>\n",
  1616. " <td>BW</td>\n",
  1617. " <td>BWP</td>\n",
  1618. " <td>3044.12735338963</td>\n",
  1619. " <td>4149.04137748834</td>\n",
  1620. " <td>4879.45946154727</td>\n",
  1621. " <td>5327.8535176786</td>\n",
  1622. " <td>5342.1403362253</td>\n",
  1623. " <td>5666.63784692568</td>\n",
  1624. " <td>5561.89823998598</td>\n",
  1625. " <td>5115.11924667202</td>\n",
  1626. " <td>6244.00257387272</td>\n",
  1627. " <td>7504.85090744898</td>\n",
  1628. " <td>6885.82968106945</td>\n",
  1629. " <td>6806.67746673071</td>\n",
  1630. " <td>7153.44432535212</td>\n",
  1631. " <td>6360.64477568565</td>\n",
  1632. " <td>NaN</td>\n",
  1633. " </tr>\n",
  1634. " <tr>\n",
  1635. " <th>26</th>\n",
  1636. " <td>Brazil</td>\n",
  1637. " <td>BR</td>\n",
  1638. " <td>BRL</td>\n",
  1639. " <td>2805.71725723054</td>\n",
  1640. " <td>3040.50649558819</td>\n",
  1641. " <td>3596.22457976056</td>\n",
  1642. " <td>4730.65346838158</td>\n",
  1643. " <td>5808.34054715979</td>\n",
  1644. " <td>7246.87010479067</td>\n",
  1645. " <td>8706.81914190374</td>\n",
  1646. " <td>8474.88106576607</td>\n",
  1647. " <td>11121.4209541496</td>\n",
  1648. " <td>13039.1216499582</td>\n",
  1649. " <td>12157.3082176473</td>\n",
  1650. " <td>12071.7779871352</td>\n",
  1651. " <td>11728.7993875108</td>\n",
  1652. " <td>8538.5899749574</td>\n",
  1653. " <td>NaN</td>\n",
  1654. " </tr>\n",
  1655. " <tr>\n",
  1656. " <th>27</th>\n",
  1657. " <td>British Virgin Islands</td>\n",
  1658. " <td>VG</td>\n",
  1659. " <td>USD</td>\n",
  1660. " <td>NaN</td>\n",
  1661. " <td>NaN</td>\n",
  1662. " <td>NaN</td>\n",
  1663. " <td>NaN</td>\n",
  1664. " <td>NaN</td>\n",
  1665. " <td>NaN</td>\n",
  1666. " <td>NaN</td>\n",
  1667. " <td>NaN</td>\n",
  1668. " <td>NaN</td>\n",
  1669. " <td>NaN</td>\n",
  1670. " <td>NaN</td>\n",
  1671. " <td>NaN</td>\n",
  1672. " <td>NaN</td>\n",
  1673. " <td>NaN</td>\n",
  1674. " <td>NaN</td>\n",
  1675. " </tr>\n",
  1676. " <tr>\n",
  1677. " <th>28</th>\n",
  1678. " <td>Brunei Darussalam</td>\n",
  1679. " <td>BN</td>\n",
  1680. " <td>BND</td>\n",
  1681. " <td>17016.9434933055</td>\n",
  1682. " <td>18758.9808946915</td>\n",
  1683. " <td>22131.9460641106</td>\n",
  1684. " <td>26337.9181126619</td>\n",
  1685. " <td>31157.6884478525</td>\n",
  1686. " <td>32707.7043073602</td>\n",
  1687. " <td>37798.3935034007</td>\n",
  1688. " <td>27726.481053695</td>\n",
  1689. " <td>31453.2243965354</td>\n",
  1690. " <td>41787.0214028978</td>\n",
  1691. " <td>41807.6533410575</td>\n",
  1692. " <td>39151.2342290391</td>\n",
  1693. " <td>40979.6419433378</td>\n",
  1694. " <td>36607.9278817468</td>\n",
  1695. " <td>NaN</td>\n",
  1696. " </tr>\n",
  1697. " <tr>\n",
  1698. " <th>29</th>\n",
  1699. " <td>Bulgaria</td>\n",
  1700. " <td>BG</td>\n",
  1701. " <td>BGN</td>\n",
  1702. " <td>2079.2289749196</td>\n",
  1703. " <td>2693.75876041107</td>\n",
  1704. " <td>3353.56414854374</td>\n",
  1705. " <td>3852.97775647268</td>\n",
  1706. " <td>4455.69022418578</td>\n",
  1707. " <td>5932.89967659315</td>\n",
  1708. " <td>7296.12247858585</td>\n",
  1709. " <td>6955.98773253421</td>\n",
  1710. " <td>6752.55217774882</td>\n",
  1711. " <td>7750.03988003072</td>\n",
  1712. " <td>7333.35507303945</td>\n",
  1713. " <td>7656.63850554922</td>\n",
  1714. " <td>7851.26542804234</td>\n",
  1715. " <td>6819.86910816324</td>\n",
  1716. " <td>NaN</td>\n",
  1717. " </tr>\n",
  1718. " <tr>\n",
  1719. " <th>...</th>\n",
  1720. " <td>...</td>\n",
  1721. " <td>...</td>\n",
  1722. " <td>...</td>\n",
  1723. " <td>...</td>\n",
  1724. " <td>...</td>\n",
  1725. " <td>...</td>\n",
  1726. " <td>...</td>\n",
  1727. " <td>...</td>\n",
  1728. " <td>...</td>\n",
  1729. " <td>...</td>\n",
  1730. " <td>...</td>\n",
  1731. " <td>...</td>\n",
  1732. " <td>...</td>\n",
  1733. " <td>...</td>\n",
  1734. " <td>...</td>\n",
  1735. " <td>...</td>\n",
  1736. " <td>...</td>\n",
  1737. " <td>...</td>\n",
  1738. " </tr>\n",
  1739. " <tr>\n",
  1740. " <th>187</th>\n",
  1741. " <td>Sweden</td>\n",
  1742. " <td>SE</td>\n",
  1743. " <td>SEK</td>\n",
  1744. " <td>29571.7044643283</td>\n",
  1745. " <td>36961.4253671424</td>\n",
  1746. " <td>42442.2204473133</td>\n",
  1747. " <td>43085.353145957</td>\n",
  1748. " <td>46256.4716010495</td>\n",
  1749. " <td>53324.3793724756</td>\n",
  1750. " <td>55746.8423811175</td>\n",
  1751. " <td>46207.0592032962</td>\n",
  1752. " <td>52076.4305245885</td>\n",
  1753. " <td>59593.6847982389</td>\n",
  1754. " <td>57134.0770682404</td>\n",
  1755. " <td>60283.24522267</td>\n",
  1756. " <td>58899.9797944845</td>\n",
  1757. " <td>50272.9415019928</td>\n",
  1758. " <td>NaN</td>\n",
  1759. " </tr>\n",
  1760. " <tr>\n",
  1761. " <th>188</th>\n",
  1762. " <td>Switzerland</td>\n",
  1763. " <td>CH</td>\n",
  1764. " <td>CHF</td>\n",
  1765. " <td>41336.7219170303</td>\n",
  1766. " <td>47960.5649721577</td>\n",
  1767. " <td>53255.9763084633</td>\n",
  1768. " <td>54797.5466345741</td>\n",
  1769. " <td>57348.9278823975</td>\n",
  1770. " <td>63223.467775151</td>\n",
  1771. " <td>72119.5608730311</td>\n",
  1772. " <td>69672.0047147337</td>\n",
  1773. " <td>74277.1205125567</td>\n",
  1774. " <td>88002.6095703805</td>\n",
  1775. " <td>83208.68654235</td>\n",
  1776. " <td>84669.2929367996</td>\n",
  1777. " <td>85610.8420285261</td>\n",
  1778. " <td>80214.7301520483</td>\n",
  1779. " <td>NaN</td>\n",
  1780. " </tr>\n",
  1781. " <tr>\n",
  1782. " <th>189</th>\n",
  1783. " <td>Syrian Arab Republic</td>\n",
  1784. " <td>SY</td>\n",
  1785. " <td>SYP</td>\n",
  1786. " <td>1269.72920825685</td>\n",
  1787. " <td>1261.42609007136</td>\n",
  1788. " <td>1419.59337922665</td>\n",
  1789. " <td>1591.53019241227</td>\n",
  1790. " <td>1779.82104926154</td>\n",
  1791. " <td>2079.98786380715</td>\n",
  1792. " <td>NaN</td>\n",
  1793. " <td>NaN</td>\n",
  1794. " <td>NaN</td>\n",
  1795. " <td>NaN</td>\n",
  1796. " <td>NaN</td>\n",
  1797. " <td>NaN</td>\n",
  1798. " <td>NaN</td>\n",
  1799. " <td>NaN</td>\n",
  1800. " <td>NaN</td>\n",
  1801. " </tr>\n",
  1802. " <tr>\n",
  1803. " <th>190</th>\n",
  1804. " <td>Tajikistan</td>\n",
  1805. " <td>TJ</td>\n",
  1806. " <td>TJS</td>\n",
  1807. " <td>190.604911236529</td>\n",
  1808. " <td>237.89319314008</td>\n",
  1809. " <td>311.424112807574</td>\n",
  1810. " <td>339.768076770367</td>\n",
  1811. " <td>407.252611650134</td>\n",
  1812. " <td>523.947651220881</td>\n",
  1813. " <td>711.503629870563</td>\n",
  1814. " <td>671.544008840534</td>\n",
  1815. " <td>744.189892165383</td>\n",
  1816. " <td>841.219870374428</td>\n",
  1817. " <td>962.439124853526</td>\n",
  1818. " <td>1048.66690599689</td>\n",
  1819. " <td>1113.36635446715</td>\n",
  1820. " <td>925.91188767081</td>\n",
  1821. " <td>NaN</td>\n",
  1822. " </tr>\n",
  1823. " <tr>\n",
  1824. " <th>191</th>\n",
  1825. " <td>Tanzania</td>\n",
  1826. " <td>TZ</td>\n",
  1827. " <td>TZS</td>\n",
  1828. " <td>310.207276508511</td>\n",
  1829. " <td>325.550773719717</td>\n",
  1830. " <td>348.052371292798</td>\n",
  1831. " <td>446.157893998536</td>\n",
  1832. " <td>475.908765113372</td>\n",
  1833. " <td>533.172396689392</td>\n",
  1834. " <td>657.728743357642</td>\n",
  1835. " <td>665.344002868127</td>\n",
  1836. " <td>708.521932325363</td>\n",
  1837. " <td>740.383900829825</td>\n",
  1838. " <td>827.52888076909</td>\n",
  1839. " <td>909.330141239446</td>\n",
  1840. " <td>954.618987954616</td>\n",
  1841. " <td>864.857502346707</td>\n",
  1842. " <td>NaN</td>\n",
  1843. " </tr>\n",
  1844. " <tr>\n",
  1845. " <th>192</th>\n",
  1846. " <td>Thailand</td>\n",
  1847. " <td>TH</td>\n",
  1848. " <td>THB</td>\n",
  1849. " <td>2093.97920641937</td>\n",
  1850. " <td>2349.38452566541</td>\n",
  1851. " <td>2643.47893487535</td>\n",
  1852. " <td>2874.38627417759</td>\n",
  1853. " <td>3351.11763286401</td>\n",
  1854. " <td>3962.7504988544</td>\n",
  1855. " <td>4384.78267515745</td>\n",
  1856. " <td>4231.14036778126</td>\n",
  1857. " <td>5111.90920222917</td>\n",
  1858. " <td>5539.49436810396</td>\n",
  1859. " <td>5915.22114668686</td>\n",
  1860. " <td>6225.05228315387</td>\n",
  1861. " <td>5969.94011583791</td>\n",
  1862. " <td>5816.44068998475</td>\n",
  1863. " <td>NaN</td>\n",
  1864. " </tr>\n",
  1865. " <tr>\n",
  1866. " <th>193</th>\n",
  1867. " <td>Timor-Leste</td>\n",
  1868. " <td>NaN</td>\n",
  1869. " <td>NaN</td>\n",
  1870. " <td>496.17975117256</td>\n",
  1871. " <td>487.394976066002</td>\n",
  1872. " <td>484.088448984765</td>\n",
  1873. " <td>501.429226481591</td>\n",
  1874. " <td>464.835169248192</td>\n",
  1875. " <td>551.720598424389</td>\n",
  1876. " <td>673.374537904</td>\n",
  1877. " <td>780.261110851448</td>\n",
  1878. " <td>875.836569271265</td>\n",
  1879. " <td>1015.71592799663</td>\n",
  1880. " <td>1127.10821457355</td>\n",
  1881. " <td>1117.73125130819</td>\n",
  1882. " <td>1131.23085071824</td>\n",
  1883. " <td>1134.42642789183</td>\n",
  1884. " <td>NaN</td>\n",
  1885. " </tr>\n",
  1886. " <tr>\n",
  1887. " <th>194</th>\n",
  1888. " <td>Togo</td>\n",
  1889. " <td>TG</td>\n",
  1890. " <td>XOF</td>\n",
  1891. " <td>286.758081572586</td>\n",
  1892. " <td>316.792068666893</td>\n",
  1893. " <td>356.830803515721</td>\n",
  1894. " <td>379.18092890047</td>\n",
  1895. " <td>384.288555620343</td>\n",
  1896. " <td>428.401561823965</td>\n",
  1897. " <td>522.625007010443</td>\n",
  1898. " <td>508.54052572385</td>\n",
  1899. " <td>496.482494202806</td>\n",
  1900. " <td>572.025703222528</td>\n",
  1901. " <td>573.207476512184</td>\n",
  1902. " <td>589.014053731293</td>\n",
  1903. " <td>629.9976439467</td>\n",
  1904. " <td>547.974683363941</td>\n",
  1905. " <td>NaN</td>\n",
  1906. " </tr>\n",
  1907. " <tr>\n",
  1908. " <th>195</th>\n",
  1909. " <td>Tonga</td>\n",
  1910. " <td>TO</td>\n",
  1911. " <td>TOP</td>\n",
  1912. " <td>1836.29040439251</td>\n",
  1913. " <td>2089.21704269256</td>\n",
  1914. " <td>2357.14647444959</td>\n",
  1915. " <td>2565.38579890357</td>\n",
  1916. " <td>2837.07547156741</td>\n",
  1917. " <td>2932.96275815712</td>\n",
  1918. " <td>3307.28239321081</td>\n",
  1919. " <td>3106.90237557772</td>\n",
  1920. " <td>3557.73718366504</td>\n",
  1921. " <td>4226.69274653294</td>\n",
  1922. " <td>4364.30924422214</td>\n",
  1923. " <td>4117.31098292096</td>\n",
  1924. " <td>4114.05211511279</td>\n",
  1925. " <td>NaN</td>\n",
  1926. " <td>NaN</td>\n",
  1927. " </tr>\n",
  1928. " <tr>\n",
  1929. " <th>196</th>\n",
  1930. " <td>Trinidad and Tobago</td>\n",
  1931. " <td>TT</td>\n",
  1932. " <td>TTD</td>\n",
  1933. " <td>7049.61006145836</td>\n",
  1934. " <td>8804.5186659639</td>\n",
  1935. " <td>10290.5191436384</td>\n",
  1936. " <td>12323.1365595732</td>\n",
  1937. " <td>14095.9958152811</td>\n",
  1938. " <td>16530.1804420146</td>\n",
  1939. " <td>21188.118565877</td>\n",
  1940. " <td>14508.8137365799</td>\n",
  1941. " <td>15840.4426914159</td>\n",
  1942. " <td>18287.3907851354</td>\n",
  1943. " <td>18322.323800986</td>\n",
  1944. " <td>20217.0322820943</td>\n",
  1945. " <td>21317.449265568</td>\n",
  1946. " <td>20444.0785895112</td>\n",
  1947. " <td>NaN</td>\n",
  1948. " </tr>\n",
  1949. " <tr>\n",
  1950. " <th>197</th>\n",
  1951. " <td>Tunisia</td>\n",
  1952. " <td>TN</td>\n",
  1953. " <td>TND</td>\n",
  1954. " <td>2373.83647757576</td>\n",
  1955. " <td>2790.00436823287</td>\n",
  1956. " <td>3139.53720163156</td>\n",
  1957. " <td>3217.96864628265</td>\n",
  1958. " <td>3394.42897986889</td>\n",
  1959. " <td>3805.15293730174</td>\n",
  1960. " <td>4342.82317730308</td>\n",
  1961. " <td>4162.5096689683</td>\n",
  1962. " <td>4176.59159013024</td>\n",
  1963. " <td>4291.87604315683</td>\n",
  1964. " <td>4179.46434367471</td>\n",
  1965. " <td>4248.89127558615</td>\n",
  1966. " <td>4328.90419734881</td>\n",
  1967. " <td>3872.51208364171</td>\n",
  1968. " <td>NaN</td>\n",
  1969. " </tr>\n",
  1970. " <tr>\n",
  1971. " <th>198</th>\n",
  1972. " <td>Turkey</td>\n",
  1973. " <td>TR</td>\n",
  1974. " <td>TRY</td>\n",
  1975. " <td>3570.54626341295</td>\n",
  1976. " <td>4586.81120315865</td>\n",
  1977. " <td>5855.53865983905</td>\n",
  1978. " <td>7117.23324132191</td>\n",
  1979. " <td>7727.27240453727</td>\n",
  1980. " <td>9309.50947782175</td>\n",
  1981. " <td>10382.3181608988</td>\n",
  1982. " <td>8623.94962718666</td>\n",
  1983. " <td>10111.5177049589</td>\n",
  1984. " <td>10538.4351203671</td>\n",
  1985. " <td>10539.3703371146</td>\n",
  1986. " <td>10800.3579763053</td>\n",
  1987. " <td>10303.8988002501</td>\n",
  1988. " <td>9130.02606479616</td>\n",
  1989. " <td>NaN</td>\n",
  1990. " </tr>\n",
  1991. " <tr>\n",
  1992. " <th>199</th>\n",
  1993. " <td>Turkmenistan</td>\n",
  1994. " <td>TM</td>\n",
  1995. " <td>TMT</td>\n",
  1996. " <td>969.970033452985</td>\n",
  1997. " <td>1286.01426124964</td>\n",
  1998. " <td>1455.93604950756</td>\n",
  1999. " <td>1706.95672639245</td>\n",
  2000. " <td>2140.45547216715</td>\n",
  2001. " <td>2606.74197588003</td>\n",
  2002. " <td>3918.93492678718</td>\n",
  2003. " <td>4059.96151102083</td>\n",
  2004. " <td>4479.01235418457</td>\n",
  2005. " <td>5724.53710231112</td>\n",
  2006. " <td>6797.72116602834</td>\n",
  2007. " <td>7480.32167773692</td>\n",
  2008. " <td>8193.72029690445</td>\n",
  2009. " <td>6947.84002260404</td>\n",
  2010. " <td>NaN</td>\n",
  2011. " </tr>\n",
  2012. " <tr>\n",
  2013. " <th>200</th>\n",
  2014. " <td>Turks and Caicos Islands</td>\n",
  2015. " <td>TC</td>\n",
  2016. " <td>USD</td>\n",
  2017. " <td>NaN</td>\n",
  2018. " <td>NaN</td>\n",
  2019. " <td>NaN</td>\n",
  2020. " <td>NaN</td>\n",
  2021. " <td>NaN</td>\n",
  2022. " <td>NaN</td>\n",
  2023. " <td>NaN</td>\n",
  2024. " <td>NaN</td>\n",
  2025. " <td>NaN</td>\n",
  2026. " <td>NaN</td>\n",
  2027. " <td>NaN</td>\n",
  2028. " <td>NaN</td>\n",
  2029. " <td>NaN</td>\n",
  2030. " <td>NaN</td>\n",
  2031. " <td>NaN</td>\n",
  2032. " </tr>\n",
  2033. " <tr>\n",
  2034. " <th>201</th>\n",
  2035. " <td>Tuvalu</td>\n",
  2036. " <td>TV</td>\n",
  2037. " <td>AUD</td>\n",
  2038. " <td>1621.33358266022</td>\n",
  2039. " <td>1901.03347628001</td>\n",
  2040. " <td>2232.60251748372</td>\n",
  2041. " <td>2252.89288563217</td>\n",
  2042. " <td>2353.35608772946</td>\n",
  2043. " <td>2768.37095732057</td>\n",
  2044. " <td>3094.62809172302</td>\n",
  2045. " <td>2763.16030537848</td>\n",
  2046. " <td>3238.37576273905</td>\n",
  2047. " <td>3993.50025430234</td>\n",
  2048. " <td>4044.19378022487</td>\n",
  2049. " <td>3880.19087861123</td>\n",
  2050. " <td>3826.90331140252</td>\n",
  2051. " <td>NaN</td>\n",
  2052. " <td>NaN</td>\n",
  2053. " </tr>\n",
  2054. " <tr>\n",
  2055. " <th>202</th>\n",
  2056. " <td>Uganda</td>\n",
  2057. " <td>UG</td>\n",
  2058. " <td>UGX</td>\n",
  2059. " <td>243.674624856652</td>\n",
  2060. " <td>241.694801118865</td>\n",
  2061. " <td>292.843015035141</td>\n",
  2062. " <td>321.435761373761</td>\n",
  2063. " <td>342.837263983568</td>\n",
  2064. " <td>409.87032601315</td>\n",
  2065. " <td>459.109775900068</td>\n",
  2066. " <td>557.523595605241</td>\n",
  2067. " <td>608.813023856722</td>\n",
  2068. " <td>591.438623816353</td>\n",
  2069. " <td>656.398072749334</td>\n",
  2070. " <td>674.341641819883</td>\n",
  2071. " <td>714.567356471156</td>\n",
  2072. " <td>675.573466220693</td>\n",
  2073. " <td>NaN</td>\n",
  2074. " </tr>\n",
  2075. " <tr>\n",
  2076. " <th>203</th>\n",
  2077. " <td>Ukraine</td>\n",
  2078. " <td>UA</td>\n",
  2079. " <td>UAH</td>\n",
  2080. " <td>879.475048622777</td>\n",
  2081. " <td>1048.52248790763</td>\n",
  2082. " <td>1367.35243333629</td>\n",
  2083. " <td>1828.71762576598</td>\n",
  2084. " <td>2303.01883093184</td>\n",
  2085. " <td>3068.60899799696</td>\n",
  2086. " <td>3891.03782318207</td>\n",
  2087. " <td>2545.4803410735</td>\n",
  2088. " <td>2973.99648071562</td>\n",
  2089. " <td>3569.75702740477</td>\n",
  2090. " <td>3855.4212801318</td>\n",
  2091. " <td>3986.28296611562</td>\n",
  2092. " <td>3065.16422265266</td>\n",
  2093. " <td>2114.95471628444</td>\n",
  2094. " <td>NaN</td>\n",
  2095. " </tr>\n",
  2096. " <tr>\n",
  2097. " <th>204</th>\n",
  2098. " <td>United Arab Emirates</td>\n",
  2099. " <td>AE</td>\n",
  2100. " <td>AED</td>\n",
  2101. " <td>32355.4095972427</td>\n",
  2102. " <td>34294.8939976005</td>\n",
  2103. " <td>37179.6818919642</td>\n",
  2104. " <td>40298.5242178562</td>\n",
  2105. " <td>42950.1005841305</td>\n",
  2106. " <td>42913.7840342254</td>\n",
  2107. " <td>45720.0178979792</td>\n",
  2108. " <td>32905.0538494054</td>\n",
  2109. " <td>34341.9112921486</td>\n",
  2110. " <td>39901.2209155518</td>\n",
  2111. " <td>41712.1242109135</td>\n",
  2112. " <td>42831.0891322689</td>\n",
  2113. " <td>43962.7136932011</td>\n",
  2114. " <td>40438.3763627115</td>\n",
  2115. " <td>NaN</td>\n",
  2116. " </tr>\n",
  2117. " <tr>\n",
  2118. " <th>205</th>\n",
  2119. " <td>United Kingdom</td>\n",
  2120. " <td>GB</td>\n",
  2121. " <td>GBP</td>\n",
  2122. " <td>28301.2083322425</td>\n",
  2123. " <td>32575.0919626199</td>\n",
  2124. " <td>38305.8726859929</td>\n",
  2125. " <td>40047.905967007</td>\n",
  2126. " <td>42534.3062613449</td>\n",
  2127. " <td>48428.1574527987</td>\n",
  2128. " <td>45195.1569273881</td>\n",
  2129. " <td>37166.2759654944</td>\n",
  2130. " <td>38292.8711313583</td>\n",
  2131. " <td>41020.3769643089</td>\n",
  2132. " <td>41294.5148008666</td>\n",
  2133. " <td>42294.8901157814</td>\n",
  2134. " <td>46278.5202128829</td>\n",
  2135. " <td>43734.0001709187</td>\n",
  2136. " <td>NaN</td>\n",
  2137. " </tr>\n",
  2138. " <tr>\n",
  2139. " <th>206</th>\n",
  2140. " <td>United States</td>\n",
  2141. " <td>US</td>\n",
  2142. " <td>USD</td>\n",
  2143. " <td>38166.0378407812</td>\n",
  2144. " <td>39677.1983481058</td>\n",
  2145. " <td>41921.8097617892</td>\n",
  2146. " <td>44307.9205848603</td>\n",
  2147. " <td>46437.0671173065</td>\n",
  2148. " <td>48061.5376613353</td>\n",
  2149. " <td>48401.4273403899</td>\n",
  2150. " <td>47001.5553496818</td>\n",
  2151. " <td>48374.0867933094</td>\n",
  2152. " <td>49781.8006563523</td>\n",
  2153. " <td>51433.0470904727</td>\n",
  2154. " <td>52660.2951049798</td>\n",
  2155. " <td>54398.4600093994</td>\n",
  2156. " <td>55836.7926308733</td>\n",
  2157. " <td>NaN</td>\n",
  2158. " </tr>\n",
  2159. " <tr>\n",
  2160. " <th>207</th>\n",
  2161. " <td>Uruguay</td>\n",
  2162. " <td>UY</td>\n",
  2163. " <td>UYU</td>\n",
  2164. " <td>4088.77254119908</td>\n",
  2165. " <td>3622.05228427976</td>\n",
  2166. " <td>4117.30885333007</td>\n",
  2167. " <td>5220.95739601735</td>\n",
  2168. " <td>5877.87960762231</td>\n",
  2169. " <td>7009.67815952936</td>\n",
  2170. " <td>9062.29053512906</td>\n",
  2171. " <td>9415.15358319032</td>\n",
  2172. " <td>11938.2750549849</td>\n",
  2173. " <td>14166.5576669096</td>\n",
  2174. " <td>15092.4720586676</td>\n",
  2175. " <td>16881.38400062</td>\n",
  2176. " <td>16737.973101175</td>\n",
  2177. " <td>15573.9009189374</td>\n",
  2178. " <td>NaN</td>\n",
  2179. " </tr>\n",
  2180. " <tr>\n",
  2181. " <th>208</th>\n",
  2182. " <td>Uzbekistan</td>\n",
  2183. " <td>UZ</td>\n",
  2184. " <td>UZS</td>\n",
  2185. " <td>383.349499748749</td>\n",
  2186. " <td>396.129968981304</td>\n",
  2187. " <td>465.119886944025</td>\n",
  2188. " <td>546.776850185552</td>\n",
  2189. " <td>642.960414644088</td>\n",
  2190. " <td>830.407694204322</td>\n",
  2191. " <td>1023.11964110698</td>\n",
  2192. " <td>1181.84735960066</td>\n",
  2193. " <td>1377.08214046938</td>\n",
  2194. " <td>1544.82777273524</td>\n",
  2195. " <td>1719.03619624155</td>\n",
  2196. " <td>1877.9645118434</td>\n",
  2197. " <td>2052.58678135925</td>\n",
  2198. " <td>2132.07244181734</td>\n",
  2199. " <td>NaN</td>\n",
  2200. " </tr>\n",
  2201. " <tr>\n",
  2202. " <th>209</th>\n",
  2203. " <td>Vanuatu</td>\n",
  2204. " <td>VU</td>\n",
  2205. " <td>VUV</td>\n",
  2206. " <td>1353.9278386398</td>\n",
  2207. " <td>1580.51066802466</td>\n",
  2208. " <td>1787.9382648014</td>\n",
  2209. " <td>1886.38830966499</td>\n",
  2210. " <td>2047.08828520065</td>\n",
  2211. " <td>2393.3346212201</td>\n",
  2212. " <td>2698.02124012432</td>\n",
  2213. " <td>2643.47578534313</td>\n",
  2214. " <td>2965.75223011673</td>\n",
  2215. " <td>3275.02398203673</td>\n",
  2216. " <td>3158.4209735273</td>\n",
  2217. " <td>3167.05530330465</td>\n",
  2218. " <td>3147.96485986836</td>\n",
  2219. " <td>NaN</td>\n",
  2220. " <td>NaN</td>\n",
  2221. " </tr>\n",
  2222. " <tr>\n",
  2223. " <th>210</th>\n",
  2224. " <td>Venezuela, RB</td>\n",
  2225. " <td>VE</td>\n",
  2226. " <td>VEF</td>\n",
  2227. " <td>3657.19374768603</td>\n",
  2228. " <td>3233.9561063252</td>\n",
  2229. " <td>4273.36537157056</td>\n",
  2230. " <td>5435.87225994853</td>\n",
  2231. " <td>6740.23677858669</td>\n",
  2232. " <td>8325.21658255278</td>\n",
  2233. " <td>11224.6467026883</td>\n",
  2234. " <td>11534.8406001136</td>\n",
  2235. " <td>13581.3533771018</td>\n",
  2236. " <td>10754.5928790654</td>\n",
  2237. " <td>12771.5950361107</td>\n",
  2238. " <td>12265.03113567</td>\n",
  2239. " <td>NaN</td>\n",
  2240. " <td>NaN</td>\n",
  2241. " <td>NaN</td>\n",
  2242. " </tr>\n",
  2243. " <tr>\n",
  2244. " <th>211</th>\n",
  2245. " <td>Vietnam</td>\n",
  2246. " <td>VN</td>\n",
  2247. " <td>VND</td>\n",
  2248. " <td>477.105876263106</td>\n",
  2249. " <td>530.861849364997</td>\n",
  2250. " <td>606.904378261988</td>\n",
  2251. " <td>699.499778976363</td>\n",
  2252. " <td>796.671573774518</td>\n",
  2253. " <td>919.209265568078</td>\n",
  2254. " <td>1164.61252461712</td>\n",
  2255. " <td>1232.36967118834</td>\n",
  2256. " <td>1333.58352635481</td>\n",
  2257. " <td>1542.67043610149</td>\n",
  2258. " <td>1754.5479738641</td>\n",
  2259. " <td>1907.56438167972</td>\n",
  2260. " <td>2052.31908380089</td>\n",
  2261. " <td>2111.13802366815</td>\n",
  2262. " <td>NaN</td>\n",
  2263. " </tr>\n",
  2264. " <tr>\n",
  2265. " <th>212</th>\n",
  2266. " <td>Virgin Islands (U.S.)</td>\n",
  2267. " <td>VI</td>\n",
  2268. " <td>USD</td>\n",
  2269. " <td>NaN</td>\n",
  2270. " <td>NaN</td>\n",
  2271. " <td>NaN</td>\n",
  2272. " <td>NaN</td>\n",
  2273. " <td>NaN</td>\n",
  2274. " <td>NaN</td>\n",
  2275. " <td>NaN</td>\n",
  2276. " <td>NaN</td>\n",
  2277. " <td>NaN</td>\n",
  2278. " <td>NaN</td>\n",
  2279. " <td>NaN</td>\n",
  2280. " <td>NaN</td>\n",
  2281. " <td>NaN</td>\n",
  2282. " <td>NaN</td>\n",
  2283. " <td>NaN</td>\n",
  2284. " </tr>\n",
  2285. " <tr>\n",
  2286. " <th>213</th>\n",
  2287. " <td>West Bank and Gaza</td>\n",
  2288. " <td>NaN</td>\n",
  2289. " <td>NaN</td>\n",
  2290. " <td>1156.21747345769</td>\n",
  2291. " <td>1257.69857009689</td>\n",
  2292. " <td>1337.56572430673</td>\n",
  2293. " <td>1455.18787518115</td>\n",
  2294. " <td>1441.46170046742</td>\n",
  2295. " <td>1575.56340027289</td>\n",
  2296. " <td>1855.45702045882</td>\n",
  2297. " <td>1963.20151865719</td>\n",
  2298. " <td>2338.71987682303</td>\n",
  2299. " <td>2663.53702496611</td>\n",
  2300. " <td>2787.16973802917</td>\n",
  2301. " <td>2992.20099455427</td>\n",
  2302. " <td>2960.77800405245</td>\n",
  2303. " <td>2866.80010121789</td>\n",
  2304. " <td>NaN</td>\n",
  2305. " </tr>\n",
  2306. " <tr>\n",
  2307. " <th>214</th>\n",
  2308. " <td>Yemen, Rep.</td>\n",
  2309. " <td>YE</td>\n",
  2310. " <td>YER</td>\n",
  2311. " <td>567.821963311624</td>\n",
  2312. " <td>607.915804267557</td>\n",
  2313. " <td>696.054960696925</td>\n",
  2314. " <td>817.082416653512</td>\n",
  2315. " <td>904.605600055261</td>\n",
  2316. " <td>1181.2151760728</td>\n",
  2317. " <td>1361.7172085227</td>\n",
  2318. " <td>1239.83711886653</td>\n",
  2319. " <td>1310.05383929542</td>\n",
  2320. " <td>1282.39883187217</td>\n",
  2321. " <td>1289.03407763668</td>\n",
  2322. " <td>1408.14619260488</td>\n",
  2323. " <td>NaN</td>\n",
  2324. " <td>NaN</td>\n",
  2325. " <td>NaN</td>\n",
  2326. " </tr>\n",
  2327. " <tr>\n",
  2328. " <th>215</th>\n",
  2329. " <td>Zambia</td>\n",
  2330. " <td>ZM</td>\n",
  2331. " <td>ZMW</td>\n",
  2332. " <td>376.468039539246</td>\n",
  2333. " <td>429.007277894455</td>\n",
  2334. " <td>530.553584072736</td>\n",
  2335. " <td>691.80945858671</td>\n",
  2336. " <td>1030.31535972563</td>\n",
  2337. " <td>1103.48657711875</td>\n",
  2338. " <td>1365.72120522548</td>\n",
  2339. " <td>1134.77299782945</td>\n",
  2340. " <td>1456.12652618031</td>\n",
  2341. " <td>1635.54730435222</td>\n",
  2342. " <td>1724.74356387435</td>\n",
  2343. " <td>1839.52248112115</td>\n",
  2344. " <td>1725.97454864009</td>\n",
  2345. " <td>1307.78861109883</td>\n",
  2346. " <td>NaN</td>\n",
  2347. " </tr>\n",
  2348. " <tr>\n",
  2349. " <th>216</th>\n",
  2350. " <td>Zimbabwe</td>\n",
  2351. " <td>ZW</td>\n",
  2352. " <td>ZWL</td>\n",
  2353. " <td>499.716414957462</td>\n",
  2354. " <td>448.373192699451</td>\n",
  2355. " <td>451.171588554028</td>\n",
  2356. " <td>443.240135984532</td>\n",
  2357. " <td>414.680115131526</td>\n",
  2358. " <td>397.956872258099</td>\n",
  2359. " <td>327.199083662345</td>\n",
  2360. " <td>594.495968478092</td>\n",
  2361. " <td>674.268695411166</td>\n",
  2362. " <td>768.556409302399</td>\n",
  2363. " <td>850.827696604891</td>\n",
  2364. " <td>905.500321786172</td>\n",
  2365. " <td>931.19818468692</td>\n",
  2366. " <td>890.416087751634</td>\n",
  2367. " <td>NaN</td>\n",
  2368. " </tr>\n",
  2369. " </tbody>\n",
  2370. "</table>\n",
  2371. "<p>217 rows × 18 columns</p>\n",
  2372. "</div>"
  2373. ],
  2374. "text/plain": [
  2375. " name country_code currency_code 2002 \\\n",
  2376. "0 Afghanistan AF AFN 192.153528278789 \n",
  2377. "1 Albania AL ALL 1453.64277660853 \n",
  2378. "2 Algeria DZ DZD 1774.29202079911 \n",
  2379. "3 American Samoa AS USD NaN \n",
  2380. "4 Andorra NaN NaN 24175.3727542522 \n",
  2381. "5 Angola AO AOA 775.765518459716 \n",
  2382. "6 Antigua and Barbuda AG XCD 10027.8562205839 \n",
  2383. "7 Argentina AR ARS 2579.18819898884 \n",
  2384. "8 Armenia AM AMD 779.829626131555 \n",
  2385. "9 Aruba AW AWG 20433.6541088167 \n",
  2386. "10 Australia AU AUD 20059.4520721372 \n",
  2387. "11 Austria AT EUR 26351.3756769542 \n",
  2388. "12 Azerbaijan AZ AZN 763.101212220367 \n",
  2389. "13 Bahamas, The BS BSD 22505.4047934793 \n",
  2390. "14 Bahrain BH BHD 13279.0457951397 \n",
  2391. "15 Bangladesh BD BDT 401.708153328187 \n",
  2392. "16 Barbados BB BBD 11674.9361829092 \n",
  2393. "17 Belarus BY BYR 1479.46532113219 \n",
  2394. "18 Belgium BE EUR 25052.3302823 \n",
  2395. "19 Belize BZ BZD 3556.61608225719 \n",
  2396. "20 Benin BJ XOF 411.959075281789 \n",
  2397. "21 Bermuda BM BMD 62583.1002034588 \n",
  2398. "22 Bhutan BT INR 897.445333164014 \n",
  2399. "23 Bolivia BO BOB 913.575853422027 \n",
  2400. "24 Bosnia and Herzegovina BA BAM 1746.48638346723 \n",
  2401. "25 Botswana BW BWP 3044.12735338963 \n",
  2402. "26 Brazil BR BRL 2805.71725723054 \n",
  2403. "27 British Virgin Islands VG USD NaN \n",
  2404. "28 Brunei Darussalam BN BND 17016.9434933055 \n",
  2405. "29 Bulgaria BG BGN 2079.2289749196 \n",
  2406. ".. ... ... ... ... \n",
  2407. "187 Sweden SE SEK 29571.7044643283 \n",
  2408. "188 Switzerland CH CHF 41336.7219170303 \n",
  2409. "189 Syrian Arab Republic SY SYP 1269.72920825685 \n",
  2410. "190 Tajikistan TJ TJS 190.604911236529 \n",
  2411. "191 Tanzania TZ TZS 310.207276508511 \n",
  2412. "192 Thailand TH THB 2093.97920641937 \n",
  2413. "193 Timor-Leste NaN NaN 496.17975117256 \n",
  2414. "194 Togo TG XOF 286.758081572586 \n",
  2415. "195 Tonga TO TOP 1836.29040439251 \n",
  2416. "196 Trinidad and Tobago TT TTD 7049.61006145836 \n",
  2417. "197 Tunisia TN TND 2373.83647757576 \n",
  2418. "198 Turkey TR TRY 3570.54626341295 \n",
  2419. "199 Turkmenistan TM TMT 969.970033452985 \n",
  2420. "200 Turks and Caicos Islands TC USD NaN \n",
  2421. "201 Tuvalu TV AUD 1621.33358266022 \n",
  2422. "202 Uganda UG UGX 243.674624856652 \n",
  2423. "203 Ukraine UA UAH 879.475048622777 \n",
  2424. "204 United Arab Emirates AE AED 32355.4095972427 \n",
  2425. "205 United Kingdom GB GBP 28301.2083322425 \n",
  2426. "206 United States US USD 38166.0378407812 \n",
  2427. "207 Uruguay UY UYU 4088.77254119908 \n",
  2428. "208 Uzbekistan UZ UZS 383.349499748749 \n",
  2429. "209 Vanuatu VU VUV 1353.9278386398 \n",
  2430. "210 Venezuela, RB VE VEF 3657.19374768603 \n",
  2431. "211 Vietnam VN VND 477.105876263106 \n",
  2432. "212 Virgin Islands (U.S.) VI USD NaN \n",
  2433. "213 West Bank and Gaza NaN NaN 1156.21747345769 \n",
  2434. "214 Yemen, Rep. YE YER 567.821963311624 \n",
  2435. "215 Zambia ZM ZMW 376.468039539246 \n",
  2436. "216 Zimbabwe ZW ZWL 499.716414957462 \n",
  2437. "\n",
  2438. " 2003 2004 2005 2006 \\\n",
  2439. "0 203.651040923182 224.914712193371 257.175794656273 280.245644106914 \n",
  2440. "1 1890.68155743544 2416.5882350701 2709.14293056201 3005.0129033756 \n",
  2441. "2 2094.89330213298 2600.00651972559 3102.03738422673 3467.54474008596 \n",
  2442. "3 NaN NaN NaN NaN \n",
  2443. "4 31742.9925847537 37235.4500323146 39990.3304085679 42417.2291456984 \n",
  2444. "5 850.075694129697 1135.60456355085 1576.16280066689 2253.83885003865 \n",
  2445. "6 10382.6309004545 10993.3692472668 12079.8656950416 13599.908857304 \n",
  2446. "7 3330.42866006847 4251.5653466058 5096.25833247505 5904.67813228342 \n",
  2447. "8 924.464009817761 1181.9684454224 1625.40776912682 2126.61866107184 \n",
  2448. "9 20834.9397101237 22566.6821576324 23302.8319880055 24015.4206122701 \n",
  2449. "10 23440.0053221856 30440.8548786229 33982.9504271591 36084.8589777475 \n",
  2450. "11 32102.9305523558 36693.4026205182 38242.0425174699 40430.993614499 \n",
  2451. "12 883.614008967961 1045.02641527642 1578.36733030667 2473.08577636837 \n",
  2452. "13 22008.4337005989 21995.5199216219 23405.8795479327 23721.1562800587 \n",
  2453. "14 14541.6160485141 16275.1804236433 18418.0726743768 19669.3195545631 \n",
  2454. "15 434.046563233432 462.274879844841 485.852888073473 495.853780201055 \n",
  2455. "16 12028.8987405468 12869.3365947615 14223.7777039775 15646.815008726 \n",
  2456. "17 1819.4790277163 2378.37489391196 3126.36777779462 3848.58620300891 \n",
  2457. "18 30743.9569254283 35589.7129457001 36967.2829204297 38852.3610339939 \n",
  2458. "19 3679.79281542143 3831.60983030588 3933.2343731798 4187.23288999866 \n",
  2459. "20 509.461088697817 570.685501333771 587.080212422838 609.018608681583 \n",
  2460. "21 66111.7252270036 70359.3191088798 75882.0338560339 83912.6977976846 \n",
  2461. "22 1009.00623184688 1107.92059564068 1257.54864008661 1346.08577480046 \n",
  2462. "23 917.36431048617 978.334757576746 1046.4278428307 1233.59297372996 \n",
  2463. "24 2192.64707824367 2619.75325753727 2928.26359035282 3351.96339986152 \n",
  2464. "25 4149.04137748834 4879.45946154727 5327.8535176786 5342.1403362253 \n",
  2465. "26 3040.50649558819 3596.22457976056 4730.65346838158 5808.34054715979 \n",
  2466. "27 NaN NaN NaN NaN \n",
  2467. "28 18758.9808946915 22131.9460641106 26337.9181126619 31157.6884478525 \n",
  2468. "29 2693.75876041107 3353.56414854374 3852.97775647268 4455.69022418578 \n",
  2469. ".. ... ... ... ... \n",
  2470. "187 36961.4253671424 42442.2204473133 43085.353145957 46256.4716010495 \n",
  2471. "188 47960.5649721577 53255.9763084633 54797.5466345741 57348.9278823975 \n",
  2472. "189 1261.42609007136 1419.59337922665 1591.53019241227 1779.82104926154 \n",
  2473. "190 237.89319314008 311.424112807574 339.768076770367 407.252611650134 \n",
  2474. "191 325.550773719717 348.052371292798 446.157893998536 475.908765113372 \n",
  2475. "192 2349.38452566541 2643.47893487535 2874.38627417759 3351.11763286401 \n",
  2476. "193 487.394976066002 484.088448984765 501.429226481591 464.835169248192 \n",
  2477. "194 316.792068666893 356.830803515721 379.18092890047 384.288555620343 \n",
  2478. "195 2089.21704269256 2357.14647444959 2565.38579890357 2837.07547156741 \n",
  2479. "196 8804.5186659639 10290.5191436384 12323.1365595732 14095.9958152811 \n",
  2480. "197 2790.00436823287 3139.53720163156 3217.96864628265 3394.42897986889 \n",
  2481. "198 4586.81120315865 5855.53865983905 7117.23324132191 7727.27240453727 \n",
  2482. "199 1286.01426124964 1455.93604950756 1706.95672639245 2140.45547216715 \n",
  2483. "200 NaN NaN NaN NaN \n",
  2484. "201 1901.03347628001 2232.60251748372 2252.89288563217 2353.35608772946 \n",
  2485. "202 241.694801118865 292.843015035141 321.435761373761 342.837263983568 \n",
  2486. "203 1048.52248790763 1367.35243333629 1828.71762576598 2303.01883093184 \n",
  2487. "204 34294.8939976005 37179.6818919642 40298.5242178562 42950.1005841305 \n",
  2488. "205 32575.0919626199 38305.8726859929 40047.905967007 42534.3062613449 \n",
  2489. "206 39677.1983481058 41921.8097617892 44307.9205848603 46437.0671173065 \n",
  2490. "207 3622.05228427976 4117.30885333007 5220.95739601735 5877.87960762231 \n",
  2491. "208 396.129968981304 465.119886944025 546.776850185552 642.960414644088 \n",
  2492. "209 1580.51066802466 1787.9382648014 1886.38830966499 2047.08828520065 \n",
  2493. "210 3233.9561063252 4273.36537157056 5435.87225994853 6740.23677858669 \n",
  2494. "211 530.861849364997 606.904378261988 699.499778976363 796.671573774518 \n",
  2495. "212 NaN NaN NaN NaN \n",
  2496. "213 1257.69857009689 1337.56572430673 1455.18787518115 1441.46170046742 \n",
  2497. "214 607.915804267557 696.054960696925 817.082416653512 904.605600055261 \n",
  2498. "215 429.007277894455 530.553584072736 691.80945858671 1030.31535972563 \n",
  2499. "216 448.373192699451 451.171588554028 443.240135984532 414.680115131526 \n",
  2500. "\n",
  2501. " 2007 2008 2009 2010 \\\n",
  2502. "0 380.400955186598 384.131681276838 458.955781585831 569.940728793286 \n",
  2503. "1 3603.01368536638 4370.53964653148 4114.13654490945 4094.35883191918 \n",
  2504. "2 3939.55993939808 4912.25194081995 3875.82209542426 4473.48644568115 \n",
  2505. "3 NaN NaN NaN NaN \n",
  2506. "4 47253.5297963111 46735.9995745016 42701.447136255 39639.386021211 \n",
  2507. "5 3151.02243105289 4242.36306234092 3678.94765447179 3886.47935432524 \n",
  2508. "6 15276.0682646698 15786.1728395062 13979.2626925883 13017.3103875487 \n",
  2509. "7 7226.27029452745 8992.58961919674 8198.56611136286 10332.0323662966 \n",
  2510. "8 3080.97095943572 3919.97547381061 2915.5839059087 3124.78401786195 \n",
  2511. "9 25921.5382341406 27549.8894224976 24640.4212441218 24289.1415161326 \n",
  2512. "10 40957.8304392487 49628.1151270179 42715.1322619629 51845.6548605562 \n",
  2513. "11 46586.6502529235 51386.3766511975 47654.1872090808 46659.8408181344 \n",
  2514. "12 3851.43786871172 5574.60380218613 4950.29479142375 5842.80578358576 \n",
  2515. "13 24306.1424243044 23657.365306222 22043.0125711709 21920.5165867583 \n",
  2516. "14 21167.6187062133 23043.0253174017 19166.7082382358 20386.0175551116 \n",
  2517. "15 543.082263122362 618.075883559283 683.614422272329 760.331935200195 \n",
  2518. "16 16461.8292691759 16569.6049618665 16526.2545517227 15901.4329353355 \n",
  2519. "17 4735.95688918873 6376.17311491284 5176.04470138203 5818.8548592158 \n",
  2520. "18 44403.8313061102 48424.5892730273 44880.5601517887 44382.8797683492 \n",
  2521. "19 4324.83101711444 4470.22079597603 4258.84287648324 4344.13666906088 \n",
  2522. "20 685.551675107742 794.870176064085 768.013476447657 732.953622726674 \n",
  2523. "21 90849.5869806436 93605.7481653976 88463.3128161375 88207.3275597322 \n",
  2524. "22 1755.16170904287 1810.57617704401 1786.81067200588 2201.29307778936 \n",
  2525. "23 1389.6317502607 1736.92401415151 1776.85718962366 1981.16010525701 \n",
  2526. "24 4107.99623197216 4974.66226666137 4586.20631315947 4475.08813004565 \n",
  2527. "25 5666.63784692568 5561.89823998598 5115.11924667202 6244.00257387272 \n",
  2528. "26 7246.87010479067 8706.81914190374 8474.88106576607 11121.4209541496 \n",
  2529. "27 NaN NaN NaN NaN \n",
  2530. "28 32707.7043073602 37798.3935034007 27726.481053695 31453.2243965354 \n",
  2531. "29 5932.89967659315 7296.12247858585 6955.98773253421 6752.55217774882 \n",
  2532. ".. ... ... ... ... \n",
  2533. "187 53324.3793724756 55746.8423811175 46207.0592032962 52076.4305245885 \n",
  2534. "188 63223.467775151 72119.5608730311 69672.0047147337 74277.1205125567 \n",
  2535. "189 2079.98786380715 NaN NaN NaN \n",
  2536. "190 523.947651220881 711.503629870563 671.544008840534 744.189892165383 \n",
  2537. "191 533.172396689392 657.728743357642 665.344002868127 708.521932325363 \n",
  2538. "192 3962.7504988544 4384.78267515745 4231.14036778126 5111.90920222917 \n",
  2539. "193 551.720598424389 673.374537904 780.261110851448 875.836569271265 \n",
  2540. "194 428.401561823965 522.625007010443 508.54052572385 496.482494202806 \n",
  2541. "195 2932.96275815712 3307.28239321081 3106.90237557772 3557.73718366504 \n",
  2542. "196 16530.1804420146 21188.118565877 14508.8137365799 15840.4426914159 \n",
  2543. "197 3805.15293730174 4342.82317730308 4162.5096689683 4176.59159013024 \n",
  2544. "198 9309.50947782175 10382.3181608988 8623.94962718666 10111.5177049589 \n",
  2545. "199 2606.74197588003 3918.93492678718 4059.96151102083 4479.01235418457 \n",
  2546. "200 NaN NaN NaN NaN \n",
  2547. "201 2768.37095732057 3094.62809172302 2763.16030537848 3238.37576273905 \n",
  2548. "202 409.87032601315 459.109775900068 557.523595605241 608.813023856722 \n",
  2549. "203 3068.60899799696 3891.03782318207 2545.4803410735 2973.99648071562 \n",
  2550. "204 42913.7840342254 45720.0178979792 32905.0538494054 34341.9112921486 \n",
  2551. "205 48428.1574527987 45195.1569273881 37166.2759654944 38292.8711313583 \n",
  2552. "206 48061.5376613353 48401.4273403899 47001.5553496818 48374.0867933094 \n",
  2553. "207 7009.67815952936 9062.29053512906 9415.15358319032 11938.2750549849 \n",
  2554. "208 830.407694204322 1023.11964110698 1181.84735960066 1377.08214046938 \n",
  2555. "209 2393.3346212201 2698.02124012432 2643.47578534313 2965.75223011673 \n",
  2556. "210 8325.21658255278 11224.6467026883 11534.8406001136 13581.3533771018 \n",
  2557. "211 919.209265568078 1164.61252461712 1232.36967118834 1333.58352635481 \n",
  2558. "212 NaN NaN NaN NaN \n",
  2559. "213 1575.56340027289 1855.45702045882 1963.20151865719 2338.71987682303 \n",
  2560. "214 1181.2151760728 1361.7172085227 1239.83711886653 1310.05383929542 \n",
  2561. "215 1103.48657711875 1365.72120522548 1134.77299782945 1456.12652618031 \n",
  2562. "216 397.956872258099 327.199083662345 594.495968478092 674.268695411166 \n",
  2563. "\n",
  2564. " 2011 2012 2013 2014 \\\n",
  2565. "0 622.379654358451 690.842629014956 653.347488111011 633.947864294639 \n",
  2566. "1 4437.8119990258 4247.83985201907 4412.34557813421 4588.64944014811 \n",
  2567. "2 5447.40397556569 5583.61615950131 5491.6144135648 5484.0668056148 \n",
  2568. "3 NaN NaN NaN NaN \n",
  2569. "4 41630.0525792977 39666.3692147448 42806.5224483021 NaN \n",
  2570. "5 4744.98762949589 5086.8484258086 5327.14889219232 5232.69050054132 \n",
  2571. "6 12817.8415733094 13525.616220134 13342.0849977054 13432.0792079208 \n",
  2572. "7 12800.2018563295 13040.306395228 13027.2048221392 12324.9387857728 \n",
  2573. "8 3417.17183599915 3565.5175749254 3716.82892254464 3873.53356580682 \n",
  2574. "9 25353.7875446441 NaN NaN NaN \n",
  2575. "10 62216.5471294133 67646.1038529626 67652.6832146189 61995.8296976 \n",
  2576. "11 51123.5613291663 48324.2540367606 50557.8038059874 51148.3588760796 \n",
  2577. "12 7189.69122920765 7393.77187697623 7811.6214184582 7886.45914367274 \n",
  2578. "13 21514.8986531628 22112.6083547268 22315.6036533886 22217.4941392075 \n",
  2579. "14 22238.7119502059 23063.1322870426 24378.9448284188 24855.2156350086 \n",
  2580. "15 838.547801702232 858.933362587621 954.396399715624 1086.80008676935 \n",
  2581. "16 15530.8942915589 15317.1390013495 15153.8213753482 15366.2926106288 \n",
  2582. "17 6305.77366247653 6721.83490773968 7722.12335060436 8025.30435552468 \n",
  2583. "18 47699.8070518961 44734.4523465803 46622.4679873931 47299.8601085612 \n",
  2584. "19 4516.23303047149 4673.55519784264 4723.59432062825 4884.3686203818 \n",
  2585. "20 799.03555913143 807.688451017232 882.638633279988 903.464924007693 \n",
  2586. "21 85973.158416455 85458.455507886 85748.0654143782 NaN \n",
  2587. "22 2485.78705216849 2452.15158793741 2383.04472990264 2560.52213174131 \n",
  2588. "23 2377.70068972888 2645.29027433174 2948.03291763073 3124.08076212353 \n",
  2589. "24 4860.78181134244 4494.64064038047 4748.04069226421 4851.66052786926 \n",
  2590. "25 7504.85090744898 6885.82968106945 6806.67746673071 7153.44432535212 \n",
  2591. "26 13039.1216499582 12157.3082176473 12071.7779871352 11728.7993875108 \n",
  2592. "27 NaN NaN NaN NaN \n",
  2593. "28 41787.0214028978 41807.6533410575 39151.2342290391 40979.6419433378 \n",
  2594. "29 7750.03988003072 7333.35507303945 7656.63850554922 7851.26542804234 \n",
  2595. ".. ... ... ... ... \n",
  2596. "187 59593.6847982389 57134.0770682404 60283.24522267 58899.9797944845 \n",
  2597. "188 88002.6095703805 83208.68654235 84669.2929367996 85610.8420285261 \n",
  2598. "189 NaN NaN NaN NaN \n",
  2599. "190 841.219870374428 962.439124853526 1048.66690599689 1113.36635446715 \n",
  2600. "191 740.383900829825 827.52888076909 909.330141239446 954.618987954616 \n",
  2601. "192 5539.49436810396 5915.22114668686 6225.05228315387 5969.94011583791 \n",
  2602. "193 1015.71592799663 1127.10821457355 1117.73125130819 1131.23085071824 \n",
  2603. "194 572.025703222528 573.207476512184 589.014053731293 629.9976439467 \n",
  2604. "195 4226.69274653294 4364.30924422214 4117.31098292096 4114.05211511279 \n",
  2605. "196 18287.3907851354 18322.323800986 20217.0322820943 21317.449265568 \n",
  2606. "197 4291.87604315683 4179.46434367471 4248.89127558615 4328.90419734881 \n",
  2607. "198 10538.4351203671 10539.3703371146 10800.3579763053 10303.8988002501 \n",
  2608. "199 5724.53710231112 6797.72116602834 7480.32167773692 8193.72029690445 \n",
  2609. "200 NaN NaN NaN NaN \n",
  2610. "201 3993.50025430234 4044.19378022487 3880.19087861123 3826.90331140252 \n",
  2611. "202 591.438623816353 656.398072749334 674.341641819883 714.567356471156 \n",
  2612. "203 3569.75702740477 3855.4212801318 3986.28296611562 3065.16422265266 \n",
  2613. "204 39901.2209155518 41712.1242109135 42831.0891322689 43962.7136932011 \n",
  2614. "205 41020.3769643089 41294.5148008666 42294.8901157814 46278.5202128829 \n",
  2615. "206 49781.8006563523 51433.0470904727 52660.2951049798 54398.4600093994 \n",
  2616. "207 14166.5576669096 15092.4720586676 16881.38400062 16737.973101175 \n",
  2617. "208 1544.82777273524 1719.03619624155 1877.9645118434 2052.58678135925 \n",
  2618. "209 3275.02398203673 3158.4209735273 3167.05530330465 3147.96485986836 \n",
  2619. "210 10754.5928790654 12771.5950361107 12265.03113567 NaN \n",
  2620. "211 1542.67043610149 1754.5479738641 1907.56438167972 2052.31908380089 \n",
  2621. "212 NaN NaN NaN NaN \n",
  2622. "213 2663.53702496611 2787.16973802917 2992.20099455427 2960.77800405245 \n",
  2623. "214 1282.39883187217 1289.03407763668 1408.14619260488 NaN \n",
  2624. "215 1635.54730435222 1724.74356387435 1839.52248112115 1725.97454864009 \n",
  2625. "216 768.556409302399 850.827696604891 905.500321786172 931.19818468692 \n",
  2626. "\n",
  2627. " 2015 2016 \n",
  2628. "0 590.269515382605 NaN \n",
  2629. "1 3965.01680558488 NaN \n",
  2630. "2 4206.03123244958 NaN \n",
  2631. "3 NaN NaN \n",
  2632. "4 NaN NaN \n",
  2633. "5 4102.11858969272 NaN \n",
  2634. "6 14128.8785463675 NaN \n",
  2635. "7 13431.8783398577 NaN \n",
  2636. "8 3499.80421759862 NaN \n",
  2637. "9 NaN NaN \n",
  2638. "10 56327.7214484289 NaN \n",
  2639. "11 43438.8630381343 NaN \n",
  2640. "12 5496.34464026248 NaN \n",
  2641. "13 22896.9236868716 NaN \n",
  2642. "14 23395.7476902684 NaN \n",
  2643. "15 1211.70153057661 NaN \n",
  2644. "16 15660.6794152314 NaN \n",
  2645. "17 5740.45649479562 NaN \n",
  2646. "18 40231.2831740081 NaN \n",
  2647. "19 4906.9406908683 NaN \n",
  2648. "20 779.067867757338 NaN \n",
  2649. "21 NaN NaN \n",
  2650. "22 2532.45446832741 NaN \n",
  2651. "23 3095.3596925636 NaN \n",
  2652. "24 4197.80730449044 NaN \n",
  2653. "25 6360.64477568565 NaN \n",
  2654. "26 8538.5899749574 NaN \n",
  2655. "27 NaN NaN \n",
  2656. "28 36607.9278817468 NaN \n",
  2657. "29 6819.86910816324 NaN \n",
  2658. ".. ... ... \n",
  2659. "187 50272.9415019928 NaN \n",
  2660. "188 80214.7301520483 NaN \n",
  2661. "189 NaN NaN \n",
  2662. "190 925.91188767081 NaN \n",
  2663. "191 864.857502346707 NaN \n",
  2664. "192 5816.44068998475 NaN \n",
  2665. "193 1134.42642789183 NaN \n",
  2666. "194 547.974683363941 NaN \n",
  2667. "195 NaN NaN \n",
  2668. "196 20444.0785895112 NaN \n",
  2669. "197 3872.51208364171 NaN \n",
  2670. "198 9130.02606479616 NaN \n",
  2671. "199 6947.84002260404 NaN \n",
  2672. "200 NaN NaN \n",
  2673. "201 NaN NaN \n",
  2674. "202 675.573466220693 NaN \n",
  2675. "203 2114.95471628444 NaN \n",
  2676. "204 40438.3763627115 NaN \n",
  2677. "205 43734.0001709187 NaN \n",
  2678. "206 55836.7926308733 NaN \n",
  2679. "207 15573.9009189374 NaN \n",
  2680. "208 2132.07244181734 NaN \n",
  2681. "209 NaN NaN \n",
  2682. "210 NaN NaN \n",
  2683. "211 2111.13802366815 NaN \n",
  2684. "212 NaN NaN \n",
  2685. "213 2866.80010121789 NaN \n",
  2686. "214 NaN NaN \n",
  2687. "215 1307.78861109883 NaN \n",
  2688. "216 890.416087751634 NaN \n",
  2689. "\n",
  2690. "[217 rows x 18 columns]"
  2691. ]
  2692. },
  2693. "execution_count": 20,
  2694. "metadata": {},
  2695. "output_type": "execute_result"
  2696. }
  2697. ],
  2698. "source": [
  2699. "# Merde gdp and code\n",
  2700. "country_gdp = pd.merge(country_gdp, country_codes, left_on='country_code_3', right_on='ISO3166-1-Alpha-3', how='left')\n",
  2701. "country_gdp.drop(['official_name_en', 'ISO3166-1-Alpha-3', 'country_code_3'], axis=1, inplace=True)\n",
  2702. "country_gdp = country_gdp.rename(columns = {'ISO3166-1-Alpha-2':'country_code',\n",
  2703. " 'ISO4217-currency_alphabetic_code':'currency_code'})\n",
  2704. "country_gdp.replace('..', np.nan, inplace=True)\n",
  2705. "\n",
  2706. "# Reorder columns\n",
  2707. "cols = list(country_gdp.columns)\n",
  2708. "cols.insert(1, cols.pop(cols.index('country_code')))\n",
  2709. "cols.insert(2, cols.pop(cols.index('currency_code')))\n",
  2710. "country_gdp = country_gdp.reindex(columns= cols)\n",
  2711. "\n",
  2712. "country_gdp"
  2713. ]
  2714. },
  2715. {
  2716. "cell_type": "code",
  2717. "execution_count": 21,
  2718. "metadata": {
  2719. "collapsed": false
  2720. },
  2721. "outputs": [],
  2722. "source": [
  2723. "def gdp(country_code, disbursal_date):\n",
  2724. " def historical_gdp(array):\n",
  2725. " array = np.array(map(float, array))\n",
  2726. " array = array[~np.isnan(array)] # Remove NaN\n",
  2727. " if len(array) == 0: # No GDP values\n",
  2728. " return 0\n",
  2729. " return float(np.mean(array, dtype=np.float64))\n",
  2730. " \n",
  2731. " # TODO: Unable to resolve country code WorldBank dataset has wrong alpha 3 codes e.g. Andorra causing issues\n",
  2732. " try:\n",
  2733. " float(country_code)\n",
  2734. " return 0\n",
  2735. " except:\n",
  2736. " if country_code not in list(country_gdp['country_code']):\n",
  2737. " return 0 # TODO: Bad solution ? \n",
  2738. " \n",
  2739. " # Get the historical average GDP if no disbursal date\n",
  2740. " all_gdp = country_gdp[country_gdp.country_code == country_code].values[0][3:]\n",
  2741. " if (disbursal_date is None): # or (country_gdp[date][country_gdp.country_code == country_code] == float('Nan')):\n",
  2742. " return historical_gdp(all_gdp)\n",
  2743. " \n",
  2744. " date = str(datetime.strptime(disbursal_date, '%Y-%m-%dT%H:%M:%SZ').year)\n",
  2745. " # Get the historical average GDP if no GDP for that year\n",
  2746. " if pd.isnull(country_gdp[date][country_gdp.country_code == country_code].values[0]):\n",
  2747. " return historical_gdp(all_gdp)\n",
  2748. " \n",
  2749. " return float(country_gdp[date][country_gdp.country_code == country_code].values[0])\n",
  2750. "\n",
  2751. "sql_ctx.registerFunction('gdp', gdp, pyspark.sql.types.FloatType())\n",
  2752. "# gdp('ZA', '2016-12-13T18:22:55Z')\n",
  2753. "\n",
  2754. "# sql_ctx.sql(\"\"\"\n",
  2755. "# SELECT \n",
  2756. "# activity, \n",
  2757. "# basket_amount,\n",
  2758. "# terms.disbursal_date,\n",
  2759. "# gdp(location.country_code, terms.disbursal_date) as gdp\n",
  2760. "# FROM loans\n",
  2761. "# LIMIT 10\n",
  2762. "# \"\"\").collect()"
  2763. ]
  2764. },
  2765. {
  2766. "cell_type": "code",
  2767. "execution_count": 22,
  2768. "metadata": {
  2769. "collapsed": false
  2770. },
  2771. "outputs": [],
  2772. "source": [
  2773. "train, validation, test = loans.randomSplit([.6, .2, .2], 101)\n",
  2774. "\n",
  2775. "\n",
  2776. "train.registerTempTable('loans_train')\n",
  2777. "validation.registerTempTable('loans_validation')\n",
  2778. "test.registerTempTable('loans_test')\n"
  2779. ]
  2780. },
  2781. {
  2782. "cell_type": "markdown",
  2783. "metadata": {},
  2784. "source": [
  2785. "\n",
  2786. "# Starts Here - Currency exchange"
  2787. ]
  2788. },
  2789. {
  2790. "cell_type": "code",
  2791. "execution_count": 23,
  2792. "metadata": {
  2793. "collapsed": false
  2794. },
  2795. "outputs": [
  2796. {
  2797. "data": {
  2798. "text/html": [
  2799. "<div>\n",
  2800. "<table border=\"1\" class=\"dataframe\">\n",
  2801. " <thead>\n",
  2802. " <tr style=\"text-align: right;\">\n",
  2803. " <th></th>\n",
  2804. " <th>Series Name</th>\n",
  2805. " <th>Series Code</th>\n",
  2806. " <th>Country Name</th>\n",
  2807. " <th>Country Code</th>\n",
  2808. " <th>2002 [YR2002]</th>\n",
  2809. " <th>2003 [YR2003]</th>\n",
  2810. " <th>2004 [YR2004]</th>\n",
  2811. " <th>2005 [YR2005]</th>\n",
  2812. " <th>2006 [YR2006]</th>\n",
  2813. " <th>2007 [YR2007]</th>\n",
  2814. " <th>2008 [YR2008]</th>\n",
  2815. " <th>2009 [YR2009]</th>\n",
  2816. " <th>2010 [YR2010]</th>\n",
  2817. " <th>2011 [YR2011]</th>\n",
  2818. " <th>2012 [YR2012]</th>\n",
  2819. " <th>2013 [YR2013]</th>\n",
  2820. " <th>2014 [YR2014]</th>\n",
  2821. " <th>2015 [YR2015]</th>\n",
  2822. " <th>2016 [YR2016]</th>\n",
  2823. " </tr>\n",
  2824. " </thead>\n",
  2825. " <tbody>\n",
  2826. " <tr>\n",
  2827. " <th>213</th>\n",
  2828. " <td>Official exchange rate (LCU per US$, period av...</td>\n",
  2829. " <td>PA.NUS.FCRF</td>\n",
  2830. " <td>West Bank and Gaza</td>\n",
  2831. " <td>WBG</td>\n",
  2832. " <td>..</td>\n",
  2833. " <td>..</td>\n",
  2834. " <td>..</td>\n",
  2835. " <td>..</td>\n",
  2836. " <td>..</td>\n",
  2837. " <td>..</td>\n",
  2838. " <td>..</td>\n",
  2839. " <td>..</td>\n",
  2840. " <td>..</td>\n",
  2841. " <td>..</td>\n",
  2842. " <td>..</td>\n",
  2843. " <td>..</td>\n",
  2844. " <td>..</td>\n",
  2845. " <td>..</td>\n",
  2846. " <td>..</td>\n",
  2847. " </tr>\n",
  2848. " <tr>\n",
  2849. " <th>214</th>\n",
  2850. " <td>Official exchange rate (LCU per US$, period av...</td>\n",
  2851. " <td>PA.NUS.FCRF</td>\n",
  2852. " <td>Yemen, Rep.</td>\n",
  2853. " <td>YEM</td>\n",
  2854. " <td>175.625</td>\n",
  2855. " <td>183.448333333333</td>\n",
  2856. " <td>184.775833333333</td>\n",
  2857. " <td>191.509166666667</td>\n",
  2858. " <td>197.049166666667</td>\n",
  2859. " <td>198.953333333333</td>\n",
  2860. " <td>199.764166666667</td>\n",
  2861. " <td>202.846666666667</td>\n",
  2862. " <td>219.59</td>\n",
  2863. " <td>213.8</td>\n",
  2864. " <td>214.350833333333</td>\n",
  2865. " <td>214.89</td>\n",
  2866. " <td>214.89</td>\n",
  2867. " <td>214.89</td>\n",
  2868. " <td>..</td>\n",
  2869. " </tr>\n",
  2870. " <tr>\n",
  2871. " <th>215</th>\n",
  2872. " <td>Official exchange rate (LCU per US$, period av...</td>\n",
  2873. " <td>PA.NUS.FCRF</td>\n",
  2874. " <td>Zambia</td>\n",
  2875. " <td>ZMB</td>\n",
  2876. " <td>4.398595</td>\n",
  2877. " <td>4.73327104649872</td>\n",
  2878. " <td>4.77887538643579</td>\n",
  2879. " <td>4.46350331051587</td>\n",
  2880. " <td>3.60307204258249</td>\n",
  2881. " <td>4.00252266503643</td>\n",
  2882. " <td>3.74566069008764</td>\n",
  2883. " <td>5.04610924521235</td>\n",
  2884. " <td>4.797136875</td>\n",
  2885. " <td>4.86066553209349</td>\n",
  2886. " <td>5.14725266514413</td>\n",
  2887. " <td>5.39588706794446</td>\n",
  2888. " <td>6.15281624812449</td>\n",
  2889. " <td>8.63235596234196</td>\n",
  2890. " <td>..</td>\n",
  2891. " </tr>\n",
  2892. " <tr>\n",
  2893. " <th>216</th>\n",
  2894. " <td>Official exchange rate (LCU per US$, period av...</td>\n",
  2895. " <td>PA.NUS.FCRF</td>\n",
  2896. " <td>Zimbabwe</td>\n",
  2897. " <td>ZWE</td>\n",
  2898. " <td>0.0550982905810338</td>\n",
  2899. " <td>0.698216071305723</td>\n",
  2900. " <td>5.07441941463195</td>\n",
  2901. " <td>22.3890396048255</td>\n",
  2902. " <td>164.547356500646</td>\n",
  2903. " <td>9686.77166954175</td>\n",
  2904. " <td>6723052073.3381</td>\n",
  2905. " <td>..</td>\n",
  2906. " <td>..</td>\n",
  2907. " <td>..</td>\n",
  2908. " <td>..</td>\n",
  2909. " <td>..</td>\n",
  2910. " <td>..</td>\n",
  2911. " <td>..</td>\n",
  2912. " <td>..</td>\n",
  2913. " </tr>\n",
  2914. " <tr>\n",
  2915. " <th>217</th>\n",
  2916. " <td>Official exchange rate (LCU per US$, period av...</td>\n",
  2917. " <td>PA.NUS.FCRF</td>\n",
  2918. " <td>Euro area</td>\n",
  2919. " <td>EMU</td>\n",
  2920. " <td>1.06255166666667</td>\n",
  2921. " <td>0.886034166666667</td>\n",
  2922. " <td>0.805365</td>\n",
  2923. " <td>0.80412</td>\n",
  2924. " <td>0.797140833333333</td>\n",
  2925. " <td>0.7306375</td>\n",
  2926. " <td>0.682674711239873</td>\n",
  2927. " <td>0.719843359785615</td>\n",
  2928. " <td>0.755044951989835</td>\n",
  2929. " <td>0.719355253609154</td>\n",
  2930. " <td>0.778293601412852</td>\n",
  2931. " <td>0.75315918184727</td>\n",
  2932. " <td>0.753730736717402</td>\n",
  2933. " <td>0.901658961641278</td>\n",
  2934. " <td>..</td>\n",
  2935. " </tr>\n",
  2936. " </tbody>\n",
  2937. "</table>\n",
  2938. "</div>"
  2939. ],
  2940. "text/plain": [
  2941. " Series Name Series Code \\\n",
  2942. "213 Official exchange rate (LCU per US$, period av... PA.NUS.FCRF \n",
  2943. "214 Official exchange rate (LCU per US$, period av... PA.NUS.FCRF \n",
  2944. "215 Official exchange rate (LCU per US$, period av... PA.NUS.FCRF \n",
  2945. "216 Official exchange rate (LCU per US$, period av... PA.NUS.FCRF \n",
  2946. "217 Official exchange rate (LCU per US$, period av... PA.NUS.FCRF \n",
  2947. "\n",
  2948. " Country Name Country Code 2002 [YR2002] 2003 [YR2003] \\\n",
  2949. "213 West Bank and Gaza WBG .. .. \n",
  2950. "214 Yemen, Rep. YEM 175.625 183.448333333333 \n",
  2951. "215 Zambia ZMB 4.398595 4.73327104649872 \n",
  2952. "216 Zimbabwe ZWE 0.0550982905810338 0.698216071305723 \n",
  2953. "217 Euro area EMU 1.06255166666667 0.886034166666667 \n",
  2954. "\n",
  2955. " 2004 [YR2004] 2005 [YR2005] 2006 [YR2006] 2007 [YR2007] \\\n",
  2956. "213 .. .. .. .. \n",
  2957. "214 184.775833333333 191.509166666667 197.049166666667 198.953333333333 \n",
  2958. "215 4.77887538643579 4.46350331051587 3.60307204258249 4.00252266503643 \n",
  2959. "216 5.07441941463195 22.3890396048255 164.547356500646 9686.77166954175 \n",
  2960. "217 0.805365 0.80412 0.797140833333333 0.7306375 \n",
  2961. "\n",
  2962. " 2008 [YR2008] 2009 [YR2009] 2010 [YR2010] \\\n",
  2963. "213 .. .. .. \n",
  2964. "214 199.764166666667 202.846666666667 219.59 \n",
  2965. "215 3.74566069008764 5.04610924521235 4.797136875 \n",
  2966. "216 6723052073.3381 .. .. \n",
  2967. "217 0.682674711239873 0.719843359785615 0.755044951989835 \n",
  2968. "\n",
  2969. " 2011 [YR2011] 2012 [YR2012] 2013 [YR2013] \\\n",
  2970. "213 .. .. .. \n",
  2971. "214 213.8 214.350833333333 214.89 \n",
  2972. "215 4.86066553209349 5.14725266514413 5.39588706794446 \n",
  2973. "216 .. .. .. \n",
  2974. "217 0.719355253609154 0.778293601412852 0.75315918184727 \n",
  2975. "\n",
  2976. " 2014 [YR2014] 2015 [YR2015] 2016 [YR2016] \n",
  2977. "213 .. .. .. \n",
  2978. "214 214.89 214.89 .. \n",
  2979. "215 6.15281624812449 8.63235596234196 .. \n",
  2980. "216 .. .. .. \n",
  2981. "217 0.753730736717402 0.901658961641278 .. "
  2982. ]
  2983. },
  2984. "execution_count": 23,
  2985. "metadata": {},
  2986. "output_type": "execute_result"
  2987. }
  2988. ],
  2989. "source": [
  2990. "currencies_raw = pd.read_csv(LOCAL_PATH + 'economic-data/currencies.csv')\n",
  2991. "currencies_raw.tail()"
  2992. ]
  2993. },
  2994. {
  2995. "cell_type": "code",
  2996. "execution_count": 24,
  2997. "metadata": {
  2998. "collapsed": true
  2999. },
  3000. "outputs": [],
  3001. "source": [
  3002. "# Cleanup\n",
  3003. "currencies = currencies_raw.drop(country_gdp_raw.columns[[0, 1]], axis=1)\n",
  3004. "currencies.columns = ['country_name', 'country_code_3', '2002', '2003', '2004', '2005', '2006',\n",
  3005. " '2007', '2008', '2009', '2010', '2011', '2012', '2013', '2014', '2015', '2016']"
  3006. ]
  3007. },
  3008. {
  3009. "cell_type": "code",
  3010. "execution_count": 25,
  3011. "metadata": {
  3012. "collapsed": false
  3013. },
  3014. "outputs": [
  3015. {
  3016. "data": {
  3017. "text/html": [
  3018. "<div>\n",
  3019. "<table border=\"1\" class=\"dataframe\">\n",
  3020. " <thead>\n",
  3021. " <tr style=\"text-align: right;\">\n",
  3022. " <th></th>\n",
  3023. " <th>country_name</th>\n",
  3024. " <th>country_code</th>\n",
  3025. " <th>currency_code</th>\n",
  3026. " <th>2002</th>\n",
  3027. " <th>2003</th>\n",
  3028. " <th>2004</th>\n",
  3029. " <th>2005</th>\n",
  3030. " <th>2006</th>\n",
  3031. " <th>2007</th>\n",
  3032. " <th>2008</th>\n",
  3033. " <th>2009</th>\n",
  3034. " <th>2010</th>\n",
  3035. " <th>2011</th>\n",
  3036. " <th>2012</th>\n",
  3037. " <th>2013</th>\n",
  3038. " <th>2014</th>\n",
  3039. " <th>2015</th>\n",
  3040. " <th>2016</th>\n",
  3041. " </tr>\n",
  3042. " </thead>\n",
  3043. " <tbody>\n",
  3044. " <tr>\n",
  3045. " <th>213</th>\n",
  3046. " <td>West Bank and Gaza</td>\n",
  3047. " <td>NaN</td>\n",
  3048. " <td>NaN</td>\n",
  3049. " <td>NaN</td>\n",
  3050. " <td>NaN</td>\n",
  3051. " <td>NaN</td>\n",
  3052. " <td>NaN</td>\n",
  3053. " <td>NaN</td>\n",
  3054. " <td>NaN</td>\n",
  3055. " <td>NaN</td>\n",
  3056. " <td>NaN</td>\n",
  3057. " <td>NaN</td>\n",
  3058. " <td>NaN</td>\n",
  3059. " <td>NaN</td>\n",
  3060. " <td>NaN</td>\n",
  3061. " <td>NaN</td>\n",
  3062. " <td>NaN</td>\n",
  3063. " <td>NaN</td>\n",
  3064. " </tr>\n",
  3065. " <tr>\n",
  3066. " <th>214</th>\n",
  3067. " <td>Yemen, Rep.</td>\n",
  3068. " <td>YE</td>\n",
  3069. " <td>YER</td>\n",
  3070. " <td>175.625</td>\n",
  3071. " <td>183.448333333333</td>\n",
  3072. " <td>184.775833333333</td>\n",
  3073. " <td>191.509166666667</td>\n",
  3074. " <td>197.049166666667</td>\n",
  3075. " <td>198.953333333333</td>\n",
  3076. " <td>199.764166666667</td>\n",
  3077. " <td>202.846666666667</td>\n",
  3078. " <td>219.59</td>\n",
  3079. " <td>213.8</td>\n",
  3080. " <td>214.350833333333</td>\n",
  3081. " <td>214.89</td>\n",
  3082. " <td>214.89</td>\n",
  3083. " <td>214.89</td>\n",
  3084. " <td>NaN</td>\n",
  3085. " </tr>\n",
  3086. " <tr>\n",
  3087. " <th>215</th>\n",
  3088. " <td>Zambia</td>\n",
  3089. " <td>ZM</td>\n",
  3090. " <td>ZMW</td>\n",
  3091. " <td>4.398595</td>\n",
  3092. " <td>4.73327104649872</td>\n",
  3093. " <td>4.77887538643579</td>\n",
  3094. " <td>4.46350331051587</td>\n",
  3095. " <td>3.60307204258249</td>\n",
  3096. " <td>4.00252266503643</td>\n",
  3097. " <td>3.74566069008764</td>\n",
  3098. " <td>5.04610924521235</td>\n",
  3099. " <td>4.797136875</td>\n",
  3100. " <td>4.86066553209349</td>\n",
  3101. " <td>5.14725266514413</td>\n",
  3102. " <td>5.39588706794446</td>\n",
  3103. " <td>6.15281624812449</td>\n",
  3104. " <td>8.63235596234196</td>\n",
  3105. " <td>NaN</td>\n",
  3106. " </tr>\n",
  3107. " <tr>\n",
  3108. " <th>216</th>\n",
  3109. " <td>Zimbabwe</td>\n",
  3110. " <td>ZW</td>\n",
  3111. " <td>ZWL</td>\n",
  3112. " <td>0.0550982905810338</td>\n",
  3113. " <td>0.698216071305723</td>\n",
  3114. " <td>5.07441941463195</td>\n",
  3115. " <td>22.3890396048255</td>\n",
  3116. " <td>164.547356500646</td>\n",
  3117. " <td>9686.77166954175</td>\n",
  3118. " <td>6723052073.3381</td>\n",
  3119. " <td>NaN</td>\n",
  3120. " <td>NaN</td>\n",
  3121. " <td>NaN</td>\n",
  3122. " <td>NaN</td>\n",
  3123. " <td>NaN</td>\n",
  3124. " <td>NaN</td>\n",
  3125. " <td>NaN</td>\n",
  3126. " <td>NaN</td>\n",
  3127. " </tr>\n",
  3128. " <tr>\n",
  3129. " <th>217</th>\n",
  3130. " <td>Euro area</td>\n",
  3131. " <td>EU</td>\n",
  3132. " <td>EMU</td>\n",
  3133. " <td>1.06255166666667</td>\n",
  3134. " <td>0.886034166666667</td>\n",
  3135. " <td>0.805365</td>\n",
  3136. " <td>0.80412</td>\n",
  3137. " <td>0.797140833333333</td>\n",
  3138. " <td>0.7306375</td>\n",
  3139. " <td>0.682674711239873</td>\n",
  3140. " <td>0.719843359785615</td>\n",
  3141. " <td>0.755044951989835</td>\n",
  3142. " <td>0.719355253609154</td>\n",
  3143. " <td>0.778293601412852</td>\n",
  3144. " <td>0.75315918184727</td>\n",
  3145. " <td>0.753730736717402</td>\n",
  3146. " <td>0.901658961641278</td>\n",
  3147. " <td>NaN</td>\n",
  3148. " </tr>\n",
  3149. " </tbody>\n",
  3150. "</table>\n",
  3151. "</div>"
  3152. ],
  3153. "text/plain": [
  3154. " country_name country_code currency_code 2002 \\\n",
  3155. "213 West Bank and Gaza NaN NaN NaN \n",
  3156. "214 Yemen, Rep. YE YER 175.625 \n",
  3157. "215 Zambia ZM ZMW 4.398595 \n",
  3158. "216 Zimbabwe ZW ZWL 0.0550982905810338 \n",
  3159. "217 Euro area EU EMU 1.06255166666667 \n",
  3160. "\n",
  3161. " 2003 2004 2005 2006 \\\n",
  3162. "213 NaN NaN NaN NaN \n",
  3163. "214 183.448333333333 184.775833333333 191.509166666667 197.049166666667 \n",
  3164. "215 4.73327104649872 4.77887538643579 4.46350331051587 3.60307204258249 \n",
  3165. "216 0.698216071305723 5.07441941463195 22.3890396048255 164.547356500646 \n",
  3166. "217 0.886034166666667 0.805365 0.80412 0.797140833333333 \n",
  3167. "\n",
  3168. " 2007 2008 2009 \\\n",
  3169. "213 NaN NaN NaN \n",
  3170. "214 198.953333333333 199.764166666667 202.846666666667 \n",
  3171. "215 4.00252266503643 3.74566069008764 5.04610924521235 \n",
  3172. "216 9686.77166954175 6723052073.3381 NaN \n",
  3173. "217 0.7306375 0.682674711239873 0.719843359785615 \n",
  3174. "\n",
  3175. " 2010 2011 2012 \\\n",
  3176. "213 NaN NaN NaN \n",
  3177. "214 219.59 213.8 214.350833333333 \n",
  3178. "215 4.797136875 4.86066553209349 5.14725266514413 \n",
  3179. "216 NaN NaN NaN \n",
  3180. "217 0.755044951989835 0.719355253609154 0.778293601412852 \n",
  3181. "\n",
  3182. " 2013 2014 2015 2016 \n",
  3183. "213 NaN NaN NaN NaN \n",
  3184. "214 214.89 214.89 214.89 NaN \n",
  3185. "215 5.39588706794446 6.15281624812449 8.63235596234196 NaN \n",
  3186. "216 NaN NaN NaN NaN \n",
  3187. "217 0.75315918184727 0.753730736717402 0.901658961641278 NaN "
  3188. ]
  3189. },
  3190. "execution_count": 25,
  3191. "metadata": {},
  3192. "output_type": "execute_result"
  3193. }
  3194. ],
  3195. "source": [
  3196. "# Get ISO 2 code\n",
  3197. "currencies = pd.merge(currencies, country_codes, left_on='country_code_3', right_on='ISO3166-1-Alpha-3', how='left')\n",
  3198. "currencies.drop(['official_name_en', 'ISO3166-1-Alpha-3', 'country_code_3'], axis=1, inplace=True)\n",
  3199. "currencies = currencies.rename(columns = {'ISO3166-1-Alpha-2':'country_code',\n",
  3200. " 'ISO4217-currency_alphabetic_code':'currency_code'})\n",
  3201. "currencies.replace('..', np.nan, inplace=True)\n",
  3202. "\n",
  3203. "# Add code for European Union\n",
  3204. "currencies.set_value(217, 'country_code', 'EU')\n",
  3205. "currencies.set_value(217, 'currency_code', 'EMU')\n",
  3206. "\n",
  3207. "# Reorder columns\n",
  3208. "cols = list(currencies.columns)\n",
  3209. "cols.insert(1, cols.pop(cols.index('country_code')))\n",
  3210. "cols.insert(2, cols.pop(cols.index('currency_code')))\n",
  3211. "currencies = currencies.reindex(columns=cols)\n",
  3212. "\n",
  3213. "currencies.tail()"
  3214. ]
  3215. },
  3216. {
  3217. "cell_type": "code",
  3218. "execution_count": 26,
  3219. "metadata": {
  3220. "collapsed": false
  3221. },
  3222. "outputs": [],
  3223. "source": [
  3224. "def xchange_rate(country_code, disbursal_date):\n",
  3225. " def historical_rates(array):\n",
  3226. " array = np.array(map(float, array))\n",
  3227. " array = array[~np.isnan(array)] # Remove NaN\n",
  3228. " if len(array) == 0: # No rate values\n",
  3229. " return 1\n",
  3230. " return float(np.mean(array, dtype=np.float64))\n",
  3231. " \n",
  3232. " eu = ['AT','BE','BG','HR','CY','CZ','DK','EE','FI','FR','DE','GR','HU','IE',\n",
  3233. " 'IT','LV','LT','LU','MT','NL','PL','PT','RO','SK','SI','ES','SE','GB']\n",
  3234. " us = ['AS','GU','MP','PR','UM','VI']\n",
  3235. " try:\n",
  3236. " float(country_code) # Country code unknown?\n",
  3237. " if pd.isnull(country_code):\n",
  3238. " return 1 # TODO: Bad solution ??\n",
  3239. " except:\n",
  3240. " if country_code in eu:\n",
  3241. " country_code = 'EU'\n",
  3242. " elif country_code in us:\n",
  3243. " country_code = 'US'\n",
  3244. " if country_code not in list(currencies['country_code']):\n",
  3245. " return 1\n",
  3246. " \n",
  3247. " \n",
  3248. " # TODO: Unable to resolve country code WorldBank dataset has wrong alpha 3 codes e.g. Andorra causing\n",
  3249. " try:\n",
  3250. " float(country_code)\n",
  3251. " return 0\n",
  3252. " except:\n",
  3253. " if country_code not in list(currencies['country_code']):\n",
  3254. " return 0 # TODO: Bad solution \n",
  3255. " \n",
  3256. " # Get the historical average exchange rate if no disbursal date\n",
  3257. " all_rates = currencies[currencies.country_code == country_code].values[0][3:]\n",
  3258. " if (disbursal_date is None): # or (country_gdp[date][country_gdp.country_code == country_code] == float('Nan')):\n",
  3259. " return historical_rates(all_rates)\n",
  3260. " \n",
  3261. " date = str(datetime.strptime(disbursal_date, '%Y-%m-%dT%H:%M:%SZ').year)\n",
  3262. " # Get the historical average exchange rate if no GDP for that year\n",
  3263. " if pd.isnull(currencies[date][currencies.country_code == country_code].values[0]):\n",
  3264. " return historical_rates(all_rates)\n",
  3265. " \n",
  3266. " return float(currencies[date][currencies.country_code == country_code].values[0])\n",
  3267. "\n",
  3268. "sql_ctx.registerFunction('xchange_rate', xchange_rate, pyspark.sql.types.FloatType())\n",
  3269. "# xchange_rate('BE', '2016-12-13T18:22:55Z') \n",
  3270. "\n",
  3271. "# sql_ctx.sql(\"\"\"\n",
  3272. "# SELECT \n",
  3273. "# xchange_rate(location.country_code, terms.disbursal_date) as xchange_rate\n",
  3274. "# FROM loans\n",
  3275. "# LIMIT 20\n",
  3276. "# \"\"\").collect()"
  3277. ]
  3278. },
  3279. {
  3280. "cell_type": "code",
  3281. "execution_count": 81,
  3282. "metadata": {
  3283. "collapsed": false
  3284. },
  3285. "outputs": [],
  3286. "source": [
  3287. "def extract_tags(tags):\n",
  3288. " value = []\n",
  3289. " if len(tags) != 0:\n",
  3290. " value = [item for (item,) in tags]\n",
  3291. " return ','.join(value)\n",
  3292. "\n",
  3293. "sql_ctx.registerFunction('extract_tags', extract_tags, pyspark.sql.types.StringType())\n",
  3294. "\n",
  3295. " \n",
  3296. "# # unpack_tags([('volunteer_pick',), ('volunteer_like',)])\n",
  3297. "\n",
  3298. "# sql_ctx.registerFunction('unpack_tags', unpack_tags)\n",
  3299. "# sql_ctx.sql(\n",
  3300. "# \"\"\"\n",
  3301. "# SELECT \n",
  3302. "# unpack_tags(tags) as tags\n",
  3303. "# FROM loans\n",
  3304. "# LIMIT 20000\n",
  3305. "# \"\"\"\n",
  3306. "# ).collect()"
  3307. ]
  3308. },
  3309. {
  3310. "cell_type": "code",
  3311. "execution_count": 82,
  3312. "metadata": {
  3313. "collapsed": false
  3314. },
  3315. "outputs": [],
  3316. "source": [
  3317. "\n",
  3318. "query = '''\n",
  3319. "SELECT\n",
  3320. " id,\n",
  3321. " activity,\n",
  3322. " size(borrowers) as num_borrowers,\n",
  3323. " male_proportion(borrowers) as male_proportion,\n",
  3324. " lender_count,\n",
  3325. " location.country,\n",
  3326. " location.country_code,\n",
  3327. " partner_id,\n",
  3328. " sector,\n",
  3329. " extract_tags(tags) as tags,\n",
  3330. " DATEDIFF(terms.disbursal_date, planned_expiration_date) as loan_length,\n",
  3331. " terms.disbursal_amount,\n",
  3332. " terms.disbursal_currency,\n",
  3333. " terms.disbursal_date,\n",
  3334. " size(terms.scheduled_payments) as num_repayments,\n",
  3335. " terms.repayment_interval,\n",
  3336. " CASE WHEN\n",
  3337. " (status = 'defaulted') OR\n",
  3338. " (status = 'deleted') OR\n",
  3339. " (status = 'issue') OR\n",
  3340. " (status = 'inactive_expired') OR\n",
  3341. " (status = 'expired') OR\n",
  3342. " (status = 'inactive') OR\n",
  3343. " (delinquent = True) THEN 1 ELSE 0 END AS bad_loan,\n",
  3344. " gdp(location.country_code, terms.disbursal_date) as gdp,\n",
  3345. " xchange_rate(location.country_code, terms.disbursal_date) as xchange_rate,\n",
  3346. " status,\n",
  3347. " delinquent\n",
  3348. " \n",
  3349. "FROM {}\n",
  3350. "WHERE\n",
  3351. " status != 'fundraising' AND\n",
  3352. " status != 'funded'\n",
  3353. "'''# Removed CASE WHEN (status = 'refunded') as it appears not to be bad loan indicator\n",
  3354. "\n",
  3355. "train_filtered = sql_ctx.sql(query.format('loans_train'))\n",
  3356. "# sparkSql.sql(query.format('loans_validation')).write.json('validation_data-filtered.json')"
  3357. ]
  3358. },
  3359. {
  3360. "cell_type": "markdown",
  3361. "metadata": {},
  3362. "source": [
  3363. "### Prediction"
  3364. ]
  3365. },
  3366. {
  3367. "cell_type": "code",
  3368. "execution_count": 163,
  3369. "metadata": {
  3370. "collapsed": false
  3371. },
  3372. "outputs": [],
  3373. "source": [
  3374. "loans_pd = sql_ctx.sql(query2.format('loans')).toPandas()"
  3375. ]
  3376. },
  3377. {
  3378. "cell_type": "code",
  3379. "execution_count": 164,
  3380. "metadata": {
  3381. "collapsed": false
  3382. },
  3383. "outputs": [
  3384. {
  3385. "data": {
  3386. "text/html": [
  3387. "<div>\n",
  3388. "<table border=\"1\" class=\"dataframe\">\n",
  3389. " <thead>\n",
  3390. " <tr style=\"text-align: right;\">\n",
  3391. " <th></th>\n",
  3392. " <th>id</th>\n",
  3393. " <th>activity</th>\n",
  3394. " <th>num_borrowers</th>\n",
  3395. " <th>male_proportion</th>\n",
  3396. " <th>lender_count</th>\n",
  3397. " <th>country</th>\n",
  3398. " <th>country_code</th>\n",
  3399. " <th>partner_id</th>\n",
  3400. " <th>sector</th>\n",
  3401. " <th>tags</th>\n",
  3402. " <th>...</th>\n",
  3403. " <th>disbursal_amount</th>\n",
  3404. " <th>disbursal_currency</th>\n",
  3405. " <th>disbursal_date</th>\n",
  3406. " <th>num_repayments</th>\n",
  3407. " <th>repayment_interval</th>\n",
  3408. " <th>bad_loan</th>\n",
  3409. " <th>gdp</th>\n",
  3410. " <th>xchange_rate</th>\n",
  3411. " <th>status</th>\n",
  3412. " <th>delinquent</th>\n",
  3413. " </tr>\n",
  3414. " </thead>\n",
  3415. " <tbody>\n",
  3416. " <tr>\n",
  3417. " <th>0</th>\n",
  3418. " <td>1224</td>\n",
  3419. " <td>Clothing Sales</td>\n",
  3420. " <td>1</td>\n",
  3421. " <td>0.0</td>\n",
  3422. " <td>0</td>\n",
  3423. " <td>Honduras</td>\n",
  3424. " <td>HN</td>\n",
  3425. " <td>5</td>\n",
  3426. " <td>Clothing</td>\n",
  3427. " <td></td>\n",
  3428. " <td>...</td>\n",
  3429. " <td>250.0</td>\n",
  3430. " <td>None</td>\n",
  3431. " <td>None</td>\n",
  3432. " <td>0</td>\n",
  3433. " <td>None</td>\n",
  3434. " <td>1</td>\n",
  3435. " <td>1884.941162</td>\n",
  3436. " <td>18.520081</td>\n",
  3437. " <td>deleted</td>\n",
  3438. " <td>None</td>\n",
  3439. " </tr>\n",
  3440. " <tr>\n",
  3441. " <th>1</th>\n",
  3442. " <td>5320</td>\n",
  3443. " <td>Food Production/Sales</td>\n",
  3444. " <td>1</td>\n",
  3445. " <td>0.0</td>\n",
  3446. " <td>7</td>\n",
  3447. " <td>Ghana</td>\n",
  3448. " <td>GH</td>\n",
  3449. " <td>19</td>\n",
  3450. " <td>Food</td>\n",
  3451. " <td></td>\n",
  3452. " <td>...</td>\n",
  3453. " <td>500.0</td>\n",
  3454. " <td>USD</td>\n",
  3455. " <td>2007-03-15T04:52:22Z</td>\n",
  3456. " <td>9</td>\n",
  3457. " <td>Monthly</td>\n",
  3458. " <td>0</td>\n",
  3459. " <td>1099.022339</td>\n",
  3460. " <td>0.935248</td>\n",
  3461. " <td>paid</td>\n",
  3462. " <td>None</td>\n",
  3463. " </tr>\n",
  3464. " <tr>\n",
  3465. " <th>2</th>\n",
  3466. " <td>9416</td>\n",
  3467. " <td>Food Production/Sales</td>\n",
  3468. " <td>1</td>\n",
  3469. " <td>0.0</td>\n",
  3470. " <td>3</td>\n",
  3471. " <td>Vietnam</td>\n",
  3472. " <td>VN</td>\n",
  3473. " <td>41</td>\n",
  3474. " <td>Food</td>\n",
  3475. " <td></td>\n",
  3476. " <td>...</td>\n",
  3477. " <td>75.0</td>\n",
  3478. " <td>USD</td>\n",
  3479. " <td>2007-05-17T22:02:42Z</td>\n",
  3480. " <td>6</td>\n",
  3481. " <td>Monthly</td>\n",
  3482. " <td>0</td>\n",
  3483. " <td>919.209290</td>\n",
  3484. " <td>16105.125000</td>\n",
  3485. " <td>paid</td>\n",
  3486. " <td>None</td>\n",
  3487. " </tr>\n",
  3488. " <tr>\n",
  3489. " <th>3</th>\n",
  3490. " <td>13512</td>\n",
  3491. " <td>Clothing Sales</td>\n",
  3492. " <td>1</td>\n",
  3493. " <td>0.0</td>\n",
  3494. " <td>10</td>\n",
  3495. " <td>Nigeria</td>\n",
  3496. " <td>NG</td>\n",
  3497. " <td>20</td>\n",
  3498. " <td>Clothing</td>\n",
  3499. " <td></td>\n",
  3500. " <td>...</td>\n",
  3501. " <td>450.0</td>\n",
  3502. " <td>USD</td>\n",
  3503. " <td>2007-07-20T16:35:52Z</td>\n",
  3504. " <td>8</td>\n",
  3505. " <td>Monthly</td>\n",
  3506. " <td>0</td>\n",
  3507. " <td>1131.147705</td>\n",
  3508. " <td>125.808105</td>\n",
  3509. " <td>paid</td>\n",
  3510. " <td>None</td>\n",
  3511. " </tr>\n",
  3512. " <tr>\n",
  3513. " <th>4</th>\n",
  3514. " <td>17608</td>\n",
  3515. " <td>Livestock</td>\n",
  3516. " <td>1</td>\n",
  3517. " <td>0.0</td>\n",
  3518. " <td>36</td>\n",
  3519. " <td>Cote D'Ivoire</td>\n",
  3520. " <td>CI</td>\n",
  3521. " <td>53</td>\n",
  3522. " <td>Agriculture</td>\n",
  3523. " <td></td>\n",
  3524. " <td>...</td>\n",
  3525. " <td>950.0</td>\n",
  3526. " <td>USD</td>\n",
  3527. " <td>2007-09-20T02:55:18Z</td>\n",
  3528. " <td>12</td>\n",
  3529. " <td>Monthly</td>\n",
  3530. " <td>0</td>\n",
  3531. " <td>1078.541504</td>\n",
  3532. " <td>479.266785</td>\n",
  3533. " <td>paid</td>\n",
  3534. " <td>None</td>\n",
  3535. " </tr>\n",
  3536. " </tbody>\n",
  3537. "</table>\n",
  3538. "<p>5 rows × 21 columns</p>\n",
  3539. "</div>"
  3540. ],
  3541. "text/plain": [
  3542. " id activity num_borrowers male_proportion lender_count \\\n",
  3543. "0 1224 Clothing Sales 1 0.0 0 \n",
  3544. "1 5320 Food Production/Sales 1 0.0 7 \n",
  3545. "2 9416 Food Production/Sales 1 0.0 3 \n",
  3546. "3 13512 Clothing Sales 1 0.0 10 \n",
  3547. "4 17608 Livestock 1 0.0 36 \n",
  3548. "\n",
  3549. " country country_code partner_id sector tags ... \\\n",
  3550. "0 Honduras HN 5 Clothing ... \n",
  3551. "1 Ghana GH 19 Food ... \n",
  3552. "2 Vietnam VN 41 Food ... \n",
  3553. "3 Nigeria NG 20 Clothing ... \n",
  3554. "4 Cote D'Ivoire CI 53 Agriculture ... \n",
  3555. "\n",
  3556. " disbursal_amount disbursal_currency disbursal_date num_repayments \\\n",
  3557. "0 250.0 None None 0 \n",
  3558. "1 500.0 USD 2007-03-15T04:52:22Z 9 \n",
  3559. "2 75.0 USD 2007-05-17T22:02:42Z 6 \n",
  3560. "3 450.0 USD 2007-07-20T16:35:52Z 8 \n",
  3561. "4 950.0 USD 2007-09-20T02:55:18Z 12 \n",
  3562. "\n",
  3563. " repayment_interval bad_loan gdp xchange_rate status delinquent \n",
  3564. "0 None 1 1884.941162 18.520081 deleted None \n",
  3565. "1 Monthly 0 1099.022339 0.935248 paid None \n",
  3566. "2 Monthly 0 919.209290 16105.125000 paid None \n",
  3567. "3 Monthly 0 1131.147705 125.808105 paid None \n",
  3568. "4 Monthly 0 1078.541504 479.266785 paid None \n",
  3569. "\n",
  3570. "[5 rows x 21 columns]"
  3571. ]
  3572. },
  3573. "execution_count": 164,
  3574. "metadata": {},
  3575. "output_type": "execute_result"
  3576. }
  3577. ],
  3578. "source": [
  3579. "loans_pd.head()"
  3580. ]
  3581. },
  3582. {
  3583. "cell_type": "code",
  3584. "execution_count": 165,
  3585. "metadata": {
  3586. "collapsed": false
  3587. },
  3588. "outputs": [],
  3589. "source": [
  3590. "from sklearn.model_selection import train_test_split\n",
  3591. "\n",
  3592. "loans_pd.fillna(0, inplace=True)"
  3593. ]
  3594. },
  3595. {
  3596. "cell_type": "code",
  3597. "execution_count": 166,
  3598. "metadata": {
  3599. "collapsed": false
  3600. },
  3601. "outputs": [],
  3602. "source": [
  3603. "loans_pd = loans_pd.drop(['status', 'delinquent'], axis=1)\n",
  3604. "loans_dummies = pd.get_dummies(loans_pd)\n",
  3605. "\n",
  3606. "train, test = train_test_split(loans_dummies, test_size=0.30, random_state=42)"
  3607. ]
  3608. },
  3609. {
  3610. "cell_type": "code",
  3611. "execution_count": 168,
  3612. "metadata": {
  3613. "collapsed": false
  3614. },
  3615. "outputs": [
  3616. {
  3617. "data": {
  3618. "text/plain": [
  3619. "11 0\n",
  3620. "47 0\n",
  3621. "85 0\n",
  3622. "28 1\n",
  3623. "93 1\n",
  3624. "Name: bad_loan, dtype: int64"
  3625. ]
  3626. },
  3627. "execution_count": 168,
  3628. "metadata": {},
  3629. "output_type": "execute_result"
  3630. }
  3631. ],
  3632. "source": [
  3633. "train_target = pd.Series(train['bad_loan'])\n",
  3634. "train_ids = pd.Series(test['id'])\n",
  3635. "\n",
  3636. "test_target = pd.Series(test['bad_loan'])\n",
  3637. "test_ids = pd.Series(test['id'])\n",
  3638. "\n",
  3639. "train = train.drop(['id', 'bad_loan'], axis=1)\n",
  3640. "test = test.drop(['id', 'bad_loan'], axis=1)\n",
  3641. "\n",
  3642. "train_target.head()"
  3643. ]
  3644. },
  3645. {
  3646. "cell_type": "code",
  3647. "execution_count": 169,
  3648. "metadata": {
  3649. "collapsed": false
  3650. },
  3651. "outputs": [],
  3652. "source": [
  3653. "train_data = train.as_matrix()\n",
  3654. "test_data = test.as_matrix()"
  3655. ]
  3656. },
  3657. {
  3658. "cell_type": "code",
  3659. "execution_count": 172,
  3660. "metadata": {
  3661. "collapsed": true
  3662. },
  3663. "outputs": [],
  3664. "source": [
  3665. "from sklearn import svm\n",
  3666. "\n",
  3667. "clf = svm.SVC(gamma=0.001, C=100.)"
  3668. ]
  3669. },
  3670. {
  3671. "cell_type": "code",
  3672. "execution_count": 173,
  3673. "metadata": {
  3674. "collapsed": false
  3675. },
  3676. "outputs": [
  3677. {
  3678. "data": {
  3679. "text/plain": [
  3680. "0.93333333333333335"
  3681. ]
  3682. },
  3683. "execution_count": 173,
  3684. "metadata": {},
  3685. "output_type": "execute_result"
  3686. }
  3687. ],
  3688. "source": [
  3689. "clf.fit(train_data, train_target)\n",
  3690. "\n",
  3691. "predicted = clf.predict(test_data)\n",
  3692. "np.mean(predicted == test_target)"
  3693. ]
  3694. },
  3695. {
  3696. "cell_type": "code",
  3697. "execution_count": null,
  3698. "metadata": {
  3699. "collapsed": true
  3700. },
  3701. "outputs": [],
  3702. "source": []
  3703. }
  3704. ],
  3705. "metadata": {
  3706. "kernelspec": {
  3707. "display_name": "Python 2",
  3708. "language": "python",
  3709. "name": "python2"
  3710. },
  3711. "language_info": {
  3712. "codemirror_mode": {
  3713. "name": "ipython",
  3714. "version": 2
  3715. },
  3716. "file_extension": ".py",
  3717. "mimetype": "text/x-python",
  3718. "name": "python",
  3719. "nbconvert_exporter": "python",
  3720. "pygments_lexer": "ipython2",
  3721. "version": "2.7.12"
  3722. }
  3723. },
  3724. "nbformat": 4,
  3725. "nbformat_minor": 0
  3726. }