-
Notifications
You must be signed in to change notification settings - Fork 0
/
Data Collection--Final
1 lines (1 loc) · 48.3 KB
/
Data Collection--Final
1
{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"provenance":[],"authorship_tag":"ABX9TyPzGRQsuyr9uHJVbwME68+X"},"kernelspec":{"name":"python3","display_name":"Python 3"},"language_info":{"name":"python"}},"cells":[{"cell_type":"code","execution_count":null,"metadata":{"id":"tJmMx-pneSyz"},"outputs":[],"source":["import pandas as pd\n","import requests\n","import json\n","import time\n","from bs4 import BeautifulSoup"]},{"cell_type":"code","source":["#Getting the indicator list from the Rapid API so I can grab the data I need\n","url = \"https://word-bank-world-development-indicators.p.rapidapi.com/indicators\"\n","\n","querystring = {\"q\":\"GDP\",\"page\":\"1\",\"pageSize\":\"20\"}\n","\n","headers = {\n","\t\"X-RapidAPI-Key\": \"f656eaaadbmsh0b64e52b2ace6edp132285jsnf4fd02571471\",\n","\t\"X-RapidAPI-Host\": \"word-bank-world-development-indicators.p.rapidapi.com\"\n","}\n","\n","response = requests.request(\"GET\", url, headers=headers, params=querystring)\n","\n","data = response.json()[\"items\"]\n","\n","data"],"metadata":{"id":"q9Lr-2oOMZ4g","colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"status":"ok","timestamp":1679350410627,"user_tz":420,"elapsed":370,"user":{"displayName":"Dhruv Darshan Naik","userId":"04801740773222038636"}},"outputId":"99a5dfc4-df5a-4c0d-b904-ccd7b630476a"},"execution_count":null,"outputs":[{"output_type":"execute_result","data":{"text/plain":["[{'indicatorCode': 'BG.GSR.NFSV.GD.ZS',\n"," 'indicatorName': 'Trade in services (% of GDP)'},\n"," {'indicatorCode': 'BM.KLT.DINV.WD.GD.ZS',\n"," 'indicatorName': 'Foreign direct investment, net outflows (% of GDP)'},\n"," {'indicatorCode': 'BN.CAB.XOKA.GD.ZS',\n"," 'indicatorName': 'Current account balance (% of GDP)'},\n"," {'indicatorCode': 'BX.KLT.DINV.WD.GD.ZS',\n"," 'indicatorName': 'Foreign direct investment, net inflows (% of GDP)'},\n"," {'indicatorCode': 'BX.TRF.PWKR.DT.GD.ZS',\n"," 'indicatorName': 'Personal remittances, received (% of GDP)'},\n"," {'indicatorCode': 'CM.MKT.LCAP.GD.ZS',\n"," 'indicatorName': 'Market capitalization of listed domestic companies (% of GDP)'},\n"," {'indicatorCode': 'CM.MKT.TRAD.GD.ZS',\n"," 'indicatorName': 'Stocks traded, total value (% of GDP)'},\n"," {'indicatorCode': 'EG.EGY.PRIM.PP.KD',\n"," 'indicatorName': 'Energy intensity level of primary energy (MJ/$2017 PPP GDP)'},\n"," {'indicatorCode': 'EG.GDP.PUSE.KO.PP',\n"," 'indicatorName': 'GDP per unit of energy use (PPP $ per kg of oil equivalent)'},\n"," {'indicatorCode': 'EG.GDP.PUSE.KO.PP.KD',\n"," 'indicatorName': 'GDP per unit of energy use (constant 2017 PPP $ per kg of oil equivalent)'},\n"," {'indicatorCode': 'EG.USE.COMM.GD.PP.KD',\n"," 'indicatorName': 'Energy use (kg of oil equivalent) per $1,000 GDP (constant 2017 PPP)'},\n"," {'indicatorCode': 'EN.ATM.CO2E.KD.GD',\n"," 'indicatorName': 'CO2 emissions (kg per 2015 US$ of GDP)'},\n"," {'indicatorCode': 'EN.ATM.CO2E.PP.GD',\n"," 'indicatorName': 'CO2 emissions (kg per PPP $ of GDP)'},\n"," {'indicatorCode': 'EN.ATM.CO2E.PP.GD.KD',\n"," 'indicatorName': 'CO2 emissions (kg per 2017 PPP $ of GDP)'},\n"," {'indicatorCode': 'ER.GDP.FWTL.M3.KD',\n"," 'indicatorName': 'Water productivity, total (constant 2015 US$ GDP per cubic meter of total freshwater withdrawal)'},\n"," {'indicatorCode': 'FD.AST.PRVT.GD.ZS',\n"," 'indicatorName': 'Domestic credit to private sector by banks (% of GDP)'},\n"," {'indicatorCode': 'FM.AST.PRVT.GD.ZS',\n"," 'indicatorName': 'Monetary Sector credit to private sector (% GDP)'},\n"," {'indicatorCode': 'FM.LBL.BMNY.GD.ZS',\n"," 'indicatorName': 'Broad money (% of GDP)'},\n"," {'indicatorCode': 'FS.AST.CGOV.GD.ZS',\n"," 'indicatorName': 'Claims on central government, etc. (% GDP)'},\n"," {'indicatorCode': 'FS.AST.DOMO.GD.ZS',\n"," 'indicatorName': 'Claims on other sectors of the domestic economy (% of GDP)'}]"]},"metadata":{},"execution_count":2}]},{"cell_type":"code","source":["#scraping the country codes from wikipedia\n","response = requests.get(\"https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3\")\n","soup = BeautifulSoup(response.text, \"html.parser\")\n","\n","country_codes = []\n","for code in soup.find_all(\"span\", attrs={\"class\": \"monospaced\"}) :\n"," country_codes.append(code.text)\n","len(country_codes)"],"metadata":{"id":"2AuzQUDqPQ2r","colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"status":"ok","timestamp":1679350410862,"user_tz":420,"elapsed":237,"user":{"displayName":"Dhruv Darshan Naik","userId":"04801740773222038636"}},"outputId":"906d58e1-1717-4a87-d78a-eb0c6e02f8de"},"execution_count":null,"outputs":[{"output_type":"execute_result","data":{"text/plain":["367"]},"metadata":{},"execution_count":3}]},{"cell_type":"code","source":["#for each country (via its code), every indicator's 2020 value is put into a \n","#list and then appended to a list of series to be concatenated when we make the\n","#data frame, where each row is a single's country collection of 2020 metrics\n","series_list_for_df = []\n","for country in country_codes :\n"," cur_row = [country]\n"," for indicator in data :\n"," url = \"https://word-bank-world-development-indicators.p.rapidapi.com/data\"\n","\n"," querystring = {\"country\": country,\"indicator\":indicator[\"indicatorCode\"]}\n","\n"," headers = {\n"," \"X-RapidAPI-Key\": \"f656eaaadbmsh0b64e52b2ace6edp132285jsnf4fd02571471\",\n"," \"X-RapidAPI-Host\": \"word-bank-world-development-indicators.p.rapidapi.com\"\n"," }\n","\n"," response = requests.request(\"GET\", url, headers=headers, params=querystring)\n"," \n"," if 'error' not in response.json() :\n"," country_data = response.json()[\"data\"][\"2020\"]\n"," if country_data is not None :\n"," cur_row.append(country_data)\n"," else :\n"," cur_row.append(0)\n"," else :\n"," cur_row.append(0)\n"," time.sleep(0.1)\n","\n"," if sum(cur_row[1:]) > 0 :\n"," cur_series = pd.Series(cur_row, index=df_indicators.columns[:len(cur_row)])\n"," series_list_for_df.append(cur_series)"],"metadata":{"id":"etEX9JSsUhvi","colab":{"base_uri":"https://localhost:8080/","height":384},"executionInfo":{"status":"error","timestamp":1679350424601,"user_tz":420,"elapsed":13617,"user":{"displayName":"Dhruv Darshan Naik","userId":"04801740773222038636"}},"outputId":"f56d0ff7-8946-403d-f1ff-fee5aa5eb228"},"execution_count":null,"outputs":[{"output_type":"error","ename":"KeyboardInterrupt","evalue":"ignored","traceback":["\u001b[0;31m---------------------------------------------------------------------------\u001b[0m","\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)","\u001b[0;32m<ipython-input-5-56b824e8dbf9>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 19\u001b[0m }\n\u001b[1;32m 20\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 21\u001b[0;31m \u001b[0mresponse\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mrequests\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrequest\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"GET\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0murl\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mheaders\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mheaders\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mparams\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mquerystring\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 22\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 23\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;34m'error'\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mresponse\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mjson\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n","\u001b[0;32m/usr/local/lib/python3.9/dist-packages/requests/api.py\u001b[0m in \u001b[0;36mrequest\u001b[0;34m(method, url, **kwargs)\u001b[0m\n\u001b[1;32m 59\u001b[0m \u001b[0;31m# cases, and look like a memory leak in others.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 60\u001b[0m \u001b[0;32mwith\u001b[0m \u001b[0msessions\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mSession\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0msession\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 61\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0msession\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrequest\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmethod\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mmethod\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0murl\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0murl\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 62\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 63\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n","\u001b[0;32m/usr/local/lib/python3.9/dist-packages/requests/sessions.py\u001b[0m in \u001b[0;36mrequest\u001b[0;34m(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)\u001b[0m\n\u001b[1;32m 527\u001b[0m }\n\u001b[1;32m 528\u001b[0m \u001b[0msend_kwargs\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mupdate\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0msettings\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 529\u001b[0;31m \u001b[0mresp\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msend\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mprep\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0msend_kwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 530\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 531\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mresp\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n","\u001b[0;32m/usr/local/lib/python3.9/dist-packages/requests/sessions.py\u001b[0m in \u001b[0;36msend\u001b[0;34m(self, request, **kwargs)\u001b[0m\n\u001b[1;32m 643\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 644\u001b[0m \u001b[0;31m# Send the request\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 645\u001b[0;31m \u001b[0mr\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0madapter\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msend\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mrequest\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 646\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 647\u001b[0m \u001b[0;31m# Total elapsed time of the request (approximately)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n","\u001b[0;32m/usr/local/lib/python3.9/dist-packages/requests/adapters.py\u001b[0m in \u001b[0;36msend\u001b[0;34m(self, request, stream, timeout, verify, cert, proxies)\u001b[0m\n\u001b[1;32m 438\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 439\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mchunked\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 440\u001b[0;31m resp = conn.urlopen(\n\u001b[0m\u001b[1;32m 441\u001b[0m \u001b[0mmethod\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mrequest\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmethod\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 442\u001b[0m \u001b[0murl\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0murl\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n","\u001b[0;32m/usr/local/lib/python3.9/dist-packages/urllib3/connectionpool.py\u001b[0m in \u001b[0;36murlopen\u001b[0;34m(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)\u001b[0m\n\u001b[1;32m 701\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 702\u001b[0m \u001b[0;31m# Make the request on the httplib connection object.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 703\u001b[0;31m httplib_response = self._make_request(\n\u001b[0m\u001b[1;32m 704\u001b[0m \u001b[0mconn\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 705\u001b[0m \u001b[0mmethod\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n","\u001b[0;32m/usr/local/lib/python3.9/dist-packages/urllib3/connectionpool.py\u001b[0m in \u001b[0;36m_make_request\u001b[0;34m(self, conn, method, url, timeout, chunked, **httplib_request_kw)\u001b[0m\n\u001b[1;32m 384\u001b[0m \u001b[0;31m# Trigger any extra validation we need to do.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 385\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 386\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_validate_conn\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mconn\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 387\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mSocketTimeout\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mBaseSSLError\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0me\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 388\u001b[0m \u001b[0;31m# Py2 raises this as a BaseSSLError, Py3 raises it as socket timeout.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n","\u001b[0;32m/usr/local/lib/python3.9/dist-packages/urllib3/connectionpool.py\u001b[0m in \u001b[0;36m_validate_conn\u001b[0;34m(self, conn)\u001b[0m\n\u001b[1;32m 1040\u001b[0m \u001b[0;31m# Force connect early to allow us to validate the connection.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1041\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mgetattr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mconn\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m\"sock\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;31m# AppEngine might not have `.sock`\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1042\u001b[0;31m \u001b[0mconn\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mconnect\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1043\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1044\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mconn\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mis_verified\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n","\u001b[0;32m/usr/local/lib/python3.9/dist-packages/urllib3/connection.py\u001b[0m in \u001b[0;36mconnect\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 417\u001b[0m \u001b[0mcontext\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mload_default_certs\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 418\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 419\u001b[0;31m self.sock = ssl_wrap_socket(\n\u001b[0m\u001b[1;32m 420\u001b[0m \u001b[0msock\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mconn\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 421\u001b[0m \u001b[0mkeyfile\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mkey_file\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n","\u001b[0;32m/usr/local/lib/python3.9/dist-packages/urllib3/util/ssl_.py\u001b[0m in \u001b[0;36mssl_wrap_socket\u001b[0;34m(sock, keyfile, certfile, cert_reqs, ca_certs, server_hostname, ssl_version, ciphers, ssl_context, ca_cert_dir, key_password, ca_cert_data, tls_in_tls)\u001b[0m\n\u001b[1;32m 447\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 448\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0msend_sni\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 449\u001b[0;31m ssl_sock = _ssl_wrap_socket_impl(\n\u001b[0m\u001b[1;32m 450\u001b[0m \u001b[0msock\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcontext\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtls_in_tls\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mserver_hostname\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mserver_hostname\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 451\u001b[0m )\n","\u001b[0;32m/usr/local/lib/python3.9/dist-packages/urllib3/util/ssl_.py\u001b[0m in \u001b[0;36m_ssl_wrap_socket_impl\u001b[0;34m(sock, ssl_context, tls_in_tls, server_hostname)\u001b[0m\n\u001b[1;32m 491\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 492\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mserver_hostname\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 493\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mssl_context\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mwrap_socket\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0msock\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mserver_hostname\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mserver_hostname\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 494\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 495\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mssl_context\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mwrap_socket\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0msock\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n","\u001b[0;32m/usr/lib/python3.9/ssl.py\u001b[0m in \u001b[0;36mwrap_socket\u001b[0;34m(self, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, session)\u001b[0m\n\u001b[1;32m 499\u001b[0m \u001b[0;31m# SSLSocket class handles server_hostname encoding before it calls\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 500\u001b[0m \u001b[0;31m# ctx._wrap_socket()\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 501\u001b[0;31m return self.sslsocket_class._create(\n\u001b[0m\u001b[1;32m 502\u001b[0m \u001b[0msock\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0msock\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 503\u001b[0m \u001b[0mserver_side\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mserver_side\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n","\u001b[0;32m/usr/lib/python3.9/ssl.py\u001b[0m in \u001b[0;36m_create\u001b[0;34m(cls, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, context, session)\u001b[0m\n\u001b[1;32m 1039\u001b[0m \u001b[0;31m# non-blocking\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1040\u001b[0m \u001b[0;32mraise\u001b[0m \u001b[0mValueError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"do_handshake_on_connect should not be specified for non-blocking sockets\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1041\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdo_handshake\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1042\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mOSError\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mValueError\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1043\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mclose\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n","\u001b[0;32m/usr/lib/python3.9/ssl.py\u001b[0m in \u001b[0;36mdo_handshake\u001b[0;34m(self, block)\u001b[0m\n\u001b[1;32m 1308\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mtimeout\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0;36m0.0\u001b[0m \u001b[0;32mand\u001b[0m \u001b[0mblock\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1309\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msettimeout\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1310\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_sslobj\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdo_handshake\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1311\u001b[0m \u001b[0;32mfinally\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1312\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msettimeout\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtimeout\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n","\u001b[0;31mKeyboardInterrupt\u001b[0m: "]}]},{"cell_type":"code","source":["#creating and formatting the dataframe\n","df_indicators = pd.concat(series_list_for_df, axis = 1, ignore_index = True)\n","df_indicators = df_indicators.transpose()"],"metadata":{"id":"ASFn0MQVVZww"},"execution_count":null,"outputs":[]},{"cell_type":"code","source":["#downloaded dataframe as a csv file so we can access it easily instead of running\n","#our data collection again every time\n","df_indicators.to_csv(\"indicator_data\")"],"metadata":{"id":"B5ECKREqcTGX"},"execution_count":null,"outputs":[]},{"cell_type":"code","source":["df_indicators = pd.read_csv(\"/content/indicator_data\")\n","df_gdp = pd.read_csv(\"/content/Sheet 2-Gdp per capita.csv\")\n","df_indicators"],"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":626},"id":"MzjGXprUd6jt","executionInfo":{"status":"ok","timestamp":1679350962776,"user_tz":420,"elapsed":274,"user":{"displayName":"Dhruv Darshan Naik","userId":"04801740773222038636"}},"outputId":"f41bf1b6-8986-4e55-c80d-5855a4f7da42"},"execution_count":null,"outputs":[{"output_type":"execute_result","data":{"text/plain":[" Unnamed: 0 country Trade in services (% of GDP) \\\n","0 0 ABW 86.595190 \n","1 1 AFG 8.971819 \n","2 2 AGO 10.573766 \n","3 3 ALB 25.741201 \n","4 4 AND 75.315533 \n",".. ... ... ... \n","189 189 ZWE 6.099718 \n","190 190 ROU 17.445623 \n","191 191 TMN 11.180270 \n","192 192 ROU 17.445623 \n","193 193 PHL 13.760298 \n","\n"," Foreign direct investment, net outflows (% of GDP) \\\n","0 0.206735 \n","1 0.185068 \n","2 0.168810 \n","3 0.331077 \n","4 0.000000 \n",".. ... \n","189 -0.019389 \n","190 0.079607 \n","191 0.055050 \n","192 0.079607 \n","193 0.984664 \n","\n"," Current account balance (% of GDP) \\\n","0 -13.548058 \n","1 -15.593120 \n","2 1.626134 \n","3 -8.687514 \n","4 15.526431 \n",".. ... \n","189 6.073066 \n","190 -5.023650 \n","191 0.000000 \n","192 -5.023650 \n","193 3.200650 \n","\n"," Foreign direct investment, net inflows (% of GDP) \\\n","0 6.572318 \n","1 0.064476 \n","2 -3.480978 \n","3 7.069484 \n","4 0.000000 \n",".. ... \n","189 0.832965 \n","190 1.443789 \n","191 0.948247 \n","192 1.443789 \n","193 1.885864 \n","\n"," Personal remittances, received (% of GDP) \\\n","0 1.401240 \n","1 3.921812 \n","2 0.015019 \n","3 9.688079 \n","4 0.000000 \n",".. ... \n","189 10.149144 \n","190 3.056266 \n","191 4.725369 \n","192 3.056266 \n","193 9.642775 \n","\n"," Market capitalization of listed domestic companies (% of GDP) \\\n","0 0.000000 \n","1 0.000000 \n","2 0.000000 \n","3 0.000000 \n","4 0.000000 \n",".. ... \n","189 0.000000 \n","190 10.225259 \n","191 164.965574 \n","192 10.225259 \n","193 75.408279 \n","\n"," Stocks traded, total value (% of GDP) \\\n","0 0.000000 \n","1 0.000000 \n","2 0.000000 \n","3 0.000000 \n","4 0.000000 \n",".. ... \n","189 0.000000 \n","190 1.175670 \n","191 0.000000 \n","192 1.175670 \n","193 9.049885 \n","\n"," Energy intensity level of primary energy (MJ/$2017 PPP GDP) ... \\\n","0 0 ... \n","1 0 ... \n","2 0 ... \n","3 0 ... \n","4 0 ... \n",".. ... ... \n","189 0 ... \n","190 0 ... \n","191 0 ... \n","192 0 ... \n","193 0 ... \n","\n"," Energy use (kg of oil equivalent) per $1,000 GDP (constant 2017 PPP) \\\n","0 0 \n","1 0 \n","2 0 \n","3 0 \n","4 0 \n",".. ... \n","189 0 \n","190 0 \n","191 0 \n","192 0 \n","193 0 \n","\n"," CO2 emissions (kg per 2015 US$ of GDP) \\\n","0 0 \n","1 0 \n","2 0 \n","3 0 \n","4 0 \n",".. ... \n","189 0 \n","190 0 \n","191 0 \n","192 0 \n","193 0 \n","\n"," CO2 emissions (kg per PPP $ of GDP) \\\n","0 0 \n","1 0 \n","2 0 \n","3 0 \n","4 0 \n",".. ... \n","189 0 \n","190 0 \n","191 0 \n","192 0 \n","193 0 \n","\n"," CO2 emissions (kg per 2017 PPP $ of GDP) \\\n","0 0 \n","1 0 \n","2 0 \n","3 0 \n","4 0 \n",".. ... \n","189 0 \n","190 0 \n","191 0 \n","192 0 \n","193 0 \n","\n"," Water productivity, total (constant 2015 US$ GDP per cubic meter of total freshwater withdrawal) \\\n","0 0 \n","1 0 \n","2 0 \n","3 0 \n","4 0 \n",".. ... \n","189 0 \n","190 0 \n","191 0 \n","192 0 \n","193 0 \n","\n"," Domestic credit to private sector by banks (% of GDP) \\\n","0 81.275811 \n","1 2.970366 \n","2 11.643342 \n","3 35.155890 \n","4 0.000000 \n",".. ... \n","189 6.391588 \n","190 25.970078 \n","191 33.722984 \n","192 25.970078 \n","193 52.035688 \n","\n"," Monetary Sector credit to private sector (% GDP) Broad money (% of GDP) \\\n","0 81.275811 107.227568 \n","1 3.071936 37.209463 \n","2 11.928710 37.545763 \n","3 35.279972 88.620531 \n","4 0.000000 0.000000 \n",".. ... ... \n","189 6.452579 17.720848 \n","190 25.970078 46.023035 \n","191 33.750977 92.440302 \n","192 25.970078 46.023035 \n","193 52.035691 90.490537 \n","\n"," Claims on central government, etc. (% GDP) \\\n","0 6.202887 \n","1 -8.253176 \n","2 18.836978 \n","3 30.277843 \n","4 0.000000 \n",".. ... \n","189 1.930916 \n","190 7.355237 \n","191 36.711790 \n","192 7.355237 \n","193 26.386096 \n","\n"," Claims on other sectors of the domestic economy (% of GDP) \n","0 0.000000 \n","1 0.000000 \n","2 13.257535 \n","3 38.938943 \n","4 0.000000 \n",".. ... \n","189 0.000000 \n","190 0.000000 \n","191 0.000000 \n","192 0.000000 \n","193 73.888818 \n","\n","[194 rows x 22 columns]"],"text/html":["\n"," <div id=\"df-d2b2d486-cf6f-4d76-8a44-17630902a436\">\n"," <div class=\"colab-df-container\">\n"," <div>\n","<style scoped>\n"," .dataframe tbody tr th:only-of-type {\n"," vertical-align: middle;\n"," }\n","\n"," .dataframe tbody tr th {\n"," vertical-align: top;\n"," }\n","\n"," .dataframe thead th {\n"," text-align: right;\n"," }\n","</style>\n","<table border=\"1\" class=\"dataframe\">\n"," <thead>\n"," <tr style=\"text-align: right;\">\n"," <th></th>\n"," <th>Unnamed: 0</th>\n"," <th>country</th>\n"," <th>Trade in services (% of GDP)</th>\n"," <th>Foreign direct investment, net outflows (% of GDP)</th>\n"," <th>Current account balance (% of GDP)</th>\n"," <th>Foreign direct investment, net inflows (% of GDP)</th>\n"," <th>Personal remittances, received (% of GDP)</th>\n"," <th>Market capitalization of listed domestic companies (% of GDP)</th>\n"," <th>Stocks traded, total value (% of GDP)</th>\n"," <th>Energy intensity level of primary energy (MJ/$2017 PPP GDP)</th>\n"," <th>...</th>\n"," <th>Energy use (kg of oil equivalent) per $1,000 GDP (constant 2017 PPP)</th>\n"," <th>CO2 emissions (kg per 2015 US$ of GDP)</th>\n"," <th>CO2 emissions (kg per PPP $ of GDP)</th>\n"," <th>CO2 emissions (kg per 2017 PPP $ of GDP)</th>\n"," <th>Water productivity, total (constant 2015 US$ GDP per cubic meter of total freshwater withdrawal)</th>\n"," <th>Domestic credit to private sector by banks (% of GDP)</th>\n"," <th>Monetary Sector credit to private sector (% GDP)</th>\n"," <th>Broad money (% of GDP)</th>\n"," <th>Claims on central government, etc. (% GDP)</th>\n"," <th>Claims on other sectors of the domestic economy (% of GDP)</th>\n"," </tr>\n"," </thead>\n"," <tbody>\n"," <tr>\n"," <th>0</th>\n"," <td>0</td>\n"," <td>ABW</td>\n"," <td>86.595190</td>\n"," <td>0.206735</td>\n"," <td>-13.548058</td>\n"," <td>6.572318</td>\n"," <td>1.401240</td>\n"," <td>0.000000</td>\n"," <td>0.000000</td>\n"," <td>0</td>\n"," <td>...</td>\n"," <td>0</td>\n"," <td>0</td>\n"," <td>0</td>\n"," <td>0</td>\n"," <td>0</td>\n"," <td>81.275811</td>\n"," <td>81.275811</td>\n"," <td>107.227568</td>\n"," <td>6.202887</td>\n"," <td>0.000000</td>\n"," </tr>\n"," <tr>\n"," <th>1</th>\n"," <td>1</td>\n"," <td>AFG</td>\n"," <td>8.971819</td>\n"," <td>0.185068</td>\n"," <td>-15.593120</td>\n"," <td>0.064476</td>\n"," <td>3.921812</td>\n"," <td>0.000000</td>\n"," <td>0.000000</td>\n"," <td>0</td>\n"," <td>...</td>\n"," <td>0</td>\n"," <td>0</td>\n"," <td>0</td>\n"," <td>0</td>\n"," <td>0</td>\n"," <td>2.970366</td>\n"," <td>3.071936</td>\n"," <td>37.209463</td>\n"," <td>-8.253176</td>\n"," <td>0.000000</td>\n"," </tr>\n"," <tr>\n"," <th>2</th>\n"," <td>2</td>\n"," <td>AGO</td>\n"," <td>10.573766</td>\n"," <td>0.168810</td>\n"," <td>1.626134</td>\n"," <td>-3.480978</td>\n"," <td>0.015019</td>\n"," <td>0.000000</td>\n"," <td>0.000000</td>\n"," <td>0</td>\n"," <td>...</td>\n"," <td>0</td>\n"," <td>0</td>\n"," <td>0</td>\n"," <td>0</td>\n"," <td>0</td>\n"," <td>11.643342</td>\n"," <td>11.928710</td>\n"," <td>37.545763</td>\n"," <td>18.836978</td>\n"," <td>13.257535</td>\n"," </tr>\n"," <tr>\n"," <th>3</th>\n"," <td>3</td>\n"," <td>ALB</td>\n"," <td>25.741201</td>\n"," <td>0.331077</td>\n"," <td>-8.687514</td>\n"," <td>7.069484</td>\n"," <td>9.688079</td>\n"," <td>0.000000</td>\n"," <td>0.000000</td>\n"," <td>0</td>\n"," <td>...</td>\n"," <td>0</td>\n"," <td>0</td>\n"," <td>0</td>\n"," <td>0</td>\n"," <td>0</td>\n"," <td>35.155890</td>\n"," <td>35.279972</td>\n"," <td>88.620531</td>\n"," <td>30.277843</td>\n"," <td>38.938943</td>\n"," </tr>\n"," <tr>\n"," <th>4</th>\n"," <td>4</td>\n"," <td>AND</td>\n"," <td>75.315533</td>\n"," <td>0.000000</td>\n"," <td>15.526431</td>\n"," <td>0.000000</td>\n"," <td>0.000000</td>\n"," <td>0.000000</td>\n"," <td>0.000000</td>\n"," <td>0</td>\n"," <td>...</td>\n"," <td>0</td>\n"," <td>0</td>\n"," <td>0</td>\n"," <td>0</td>\n"," <td>0</td>\n"," <td>0.000000</td>\n"," <td>0.000000</td>\n"," <td>0.000000</td>\n"," <td>0.000000</td>\n"," <td>0.000000</td>\n"," </tr>\n"," <tr>\n"," <th>...</th>\n"," <td>...</td>\n"," <td>...</td>\n"," <td>...</td>\n"," <td>...</td>\n"," <td>...</td>\n"," <td>...</td>\n"," <td>...</td>\n"," <td>...</td>\n"," <td>...</td>\n"," <td>...</td>\n"," <td>...</td>\n"," <td>...</td>\n"," <td>...</td>\n"," <td>...</td>\n"," <td>...</td>\n"," <td>...</td>\n"," <td>...</td>\n"," <td>...</td>\n"," <td>...</td>\n"," <td>...</td>\n"," <td>...</td>\n"," </tr>\n"," <tr>\n"," <th>189</th>\n"," <td>189</td>\n"," <td>ZWE</td>\n"," <td>6.099718</td>\n"," <td>-0.019389</td>\n"," <td>6.073066</td>\n"," <td>0.832965</td>\n"," <td>10.149144</td>\n"," <td>0.000000</td>\n"," <td>0.000000</td>\n"," <td>0</td>\n"," <td>...</td>\n"," <td>0</td>\n"," <td>0</td>\n"," <td>0</td>\n"," <td>0</td>\n"," <td>0</td>\n"," <td>6.391588</td>\n"," <td>6.452579</td>\n"," <td>17.720848</td>\n"," <td>1.930916</td>\n"," <td>0.000000</td>\n"," </tr>\n"," <tr>\n"," <th>190</th>\n"," <td>190</td>\n"," <td>ROU</td>\n"," <td>17.445623</td>\n"," <td>0.079607</td>\n"," <td>-5.023650</td>\n"," <td>1.443789</td>\n"," <td>3.056266</td>\n"," <td>10.225259</td>\n"," <td>1.175670</td>\n"," <td>0</td>\n"," <td>...</td>\n"," <td>0</td>\n"," <td>0</td>\n"," <td>0</td>\n"," <td>0</td>\n"," <td>0</td>\n"," <td>25.970078</td>\n"," <td>25.970078</td>\n"," <td>46.023035</td>\n"," <td>7.355237</td>\n"," <td>0.000000</td>\n"," </tr>\n"," <tr>\n"," <th>191</th>\n"," <td>191</td>\n"," <td>TMN</td>\n"," <td>11.180270</td>\n"," <td>0.055050</td>\n"," <td>0.000000</td>\n"," <td>0.948247</td>\n"," <td>4.725369</td>\n"," <td>164.965574</td>\n"," <td>0.000000</td>\n"," <td>0</td>\n"," <td>...</td>\n"," <td>0</td>\n"," <td>0</td>\n"," <td>0</td>\n"," <td>0</td>\n"," <td>0</td>\n"," <td>33.722984</td>\n"," <td>33.750977</td>\n"," <td>92.440302</td>\n"," <td>36.711790</td>\n"," <td>0.000000</td>\n"," </tr>\n"," <tr>\n"," <th>192</th>\n"," <td>192</td>\n"," <td>ROU</td>\n"," <td>17.445623</td>\n"," <td>0.079607</td>\n"," <td>-5.023650</td>\n"," <td>1.443789</td>\n"," <td>3.056266</td>\n"," <td>10.225259</td>\n"," <td>1.175670</td>\n"," <td>0</td>\n"," <td>...</td>\n"," <td>0</td>\n"," <td>0</td>\n"," <td>0</td>\n"," <td>0</td>\n"," <td>0</td>\n"," <td>25.970078</td>\n"," <td>25.970078</td>\n"," <td>46.023035</td>\n"," <td>7.355237</td>\n"," <td>0.000000</td>\n"," </tr>\n"," <tr>\n"," <th>193</th>\n"," <td>193</td>\n"," <td>PHL</td>\n"," <td>13.760298</td>\n"," <td>0.984664</td>\n"," <td>3.200650</td>\n"," <td>1.885864</td>\n"," <td>9.642775</td>\n"," <td>75.408279</td>\n"," <td>9.049885</td>\n"," <td>0</td>\n"," <td>...</td>\n"," <td>0</td>\n"," <td>0</td>\n"," <td>0</td>\n"," <td>0</td>\n"," <td>0</td>\n"," <td>52.035688</td>\n"," <td>52.035691</td>\n"," <td>90.490537</td>\n"," <td>26.386096</td>\n"," <td>73.888818</td>\n"," </tr>\n"," </tbody>\n","</table>\n","<p>194 rows × 22 columns</p>\n","</div>\n"," <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-d2b2d486-cf6f-4d76-8a44-17630902a436')\"\n"," title=\"Convert this dataframe to an interactive table.\"\n"," style=\"display:none;\">\n"," \n"," <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n"," width=\"24px\">\n"," <path d=\"M0 0h24v24H0V0z\" fill=\"none\"/>\n"," <path d=\"M18.56 5.44l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94zm-11 1L8.5 8.5l.94-2.06 2.06-.94-2.06-.94L8.5 2.5l-.94 2.06-2.06.94zm10 10l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94z\"/><path d=\"M17.41 7.96l-1.37-1.37c-.4-.4-.92-.59-1.43-.59-.52 0-1.04.2-1.43.59L10.3 9.45l-7.72 7.72c-.78.78-.78 2.05 0 2.83L4 21.41c.39.39.9.59 1.41.59.51 0 1.02-.2 1.41-.59l7.78-7.78 2.81-2.81c.8-.78.8-2.07 0-2.86zM5.41 20L4 18.59l7.72-7.72 1.47 1.35L5.41 20z\"/>\n"," </svg>\n"," </button>\n"," \n"," <style>\n"," .colab-df-container {\n"," display:flex;\n"," flex-wrap:wrap;\n"," gap: 12px;\n"," }\n","\n"," .colab-df-convert {\n"," background-color: #E8F0FE;\n"," border: none;\n"," border-radius: 50%;\n"," cursor: pointer;\n"," display: none;\n"," fill: #1967D2;\n"," height: 32px;\n"," padding: 0 0 0 0;\n"," width: 32px;\n"," }\n","\n"," .colab-df-convert:hover {\n"," background-color: #E2EBFA;\n"," box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n"," fill: #174EA6;\n"," }\n","\n"," [theme=dark] .colab-df-convert {\n"," background-color: #3B4455;\n"," fill: #D2E3FC;\n"," }\n","\n"," [theme=dark] .colab-df-convert:hover {\n"," background-color: #434B5C;\n"," box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n"," filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n"," fill: #FFFFFF;\n"," }\n"," </style>\n","\n"," <script>\n"," const buttonEl =\n"," document.querySelector('#df-d2b2d486-cf6f-4d76-8a44-17630902a436 button.colab-df-convert');\n"," buttonEl.style.display =\n"," google.colab.kernel.accessAllowed ? 'block' : 'none';\n","\n"," async function convertToInteractive(key) {\n"," const element = document.querySelector('#df-d2b2d486-cf6f-4d76-8a44-17630902a436');\n"," const dataTable =\n"," await google.colab.kernel.invokeFunction('convertToInteractive',\n"," [key], {});\n"," if (!dataTable) return;\n","\n"," const docLinkHtml = 'Like what you see? Visit the ' +\n"," '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n"," + ' to learn more about interactive tables.';\n"," element.innerHTML = '';\n"," dataTable['output_type'] = 'display_data';\n"," await google.colab.output.renderOutput(dataTable, element);\n"," const docLink = document.createElement('div');\n"," docLink.innerHTML = docLinkHtml;\n"," element.appendChild(docLink);\n"," }\n"," </script>\n"," </div>\n"," </div>\n"," "]},"metadata":{},"execution_count":26}]},{"cell_type":"code","source":["df_gdp.keys()"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"8coM7ue7eY4c","executionInfo":{"status":"ok","timestamp":1679350976278,"user_tz":420,"elapsed":4,"user":{"displayName":"Dhruv Darshan Naik","userId":"04801740773222038636"}},"outputId":"b1e20469-b09a-4f0e-efeb-676e0803cfbf"},"execution_count":null,"outputs":[{"output_type":"execute_result","data":{"text/plain":["Index(['Unnamed: 0', '2020'], dtype='object')"]},"metadata":{},"execution_count":28}]},{"cell_type":"code","source":["#joining the dataframe of indicators with a dataframe of gdp per capita\n","df_indicators = df_indicators.merge(\n"," df_gdp, \n"," left_on = \"country\", \n"," right_on = 'Unnamed: 0',\n"," how = \"inner\"\n",")"],"metadata":{"id":"X7i4N5-keMLr"},"execution_count":null,"outputs":[]},{"cell_type":"code","source":["#saving to csv so we can access for data exploration/analysis\n","df_indicators.to_csv(\"merged_indicator_data_per_capita\")\n"],"metadata":{"id":"BNlBrncIenjv"},"execution_count":null,"outputs":[]}]}