# -*- coding: utf-8 -*-
"""Club convergence in the carbon intensity of electricity: Evidence from 191 countries, 2000–2024

GOMD arastirma makalesi 03 - makaledeki tum sayilari, tablolari ve sekilleri ureten kod (Google Colab surumu).
Colab: kodu tek bir hucreye yapistirip calistirin ya da .ipynb dosyasini Dosya > Not defteri yukle ile acin.
Kaynak: GOMD acik veri platformu (https://gomd.pirireis.edu.tr) - Piri Reis Universitesi ve
T.C. Cevre, Sehircilik ve Iklim Degisikligi Bakanligi Cevre Yonetimi Genel Mudurlugu.
"""

# # Club convergence in the carbon intensity of electricity: Evidence from 191 countries, 2000–2024
#
# Bu not defteri makaledeki **tüm sayıları, tabloları ve şekilleri** üreten kodun Colab sürümüdür (makalenin replikasyon paketindeki betiklerle aynı kod, hücrelere bölünmüş hâlde).
#
# **Çalıştırma:** Çalışma zamanı → Tümünü çalıştır (*Runtime → Run all*). Tahmini süre: 15–25 dakika (veri çekimi yaklaşık 10 dakika).
#
# **Veri:** Varsayılan olarak veriler GOMD açık veri API'sinden canlı çekilir (`VERI_KAYNAGI = "api"`). Makaledeki sayıları birebir yeniden üretmek için replikasyon paketi ZIP'ini yükleyebilirsiniz (`VERI_KAYNAGI = "zip"`): API'deki seriler kaynak kurumlar tarafından güncellenirse sonuçlar küçük farklar gösterebilir. Veri çekim tarihi makalede 8 Kasım 2026'dır.
#
# Şekiller hem hücre altında görünür hem `fig/` klasörüne, sayısal sonuçlar `out/` klasörüne yazılır. Son hücre hepsini ZIP olarak indirir.

# ## 0. Kurulum

# Installs the packages used in the paper and the GOMD Python client. If Colab asks to restart the session, restart and run all cells again.
# [Colab Magic] !pip install -q statsmodels scikit-learn scipy
# [Colab Magic] !pip install -q --upgrade gomd

VERI_KAYNAGI = "api"   # "api": live from GOMD; "zip": upload the replication package ZIP (exact reproduction)
import os
os.makedirs("/content/rp03", exist_ok=True); os.chdir("/content/rp03")
for d in ("data", "out", "fig"): os.makedirs(d, exist_ok=True)
if VERI_KAYNAGI == "zip":
    import zipfile, glob, shutil
    from google.colab import files
    up = files.upload()                      # choose *_replication_package.zip
    with zipfile.ZipFile(next(iter(up))) as z:
        for n in z.namelist():
            if n.startswith("data/"): z.extract(n, ".")
    print(sorted(os.listdir("data")))
print("Calisma klasoru:", os.getcwd())

# ## 1. Veri

# Data from the public GOMD open data API (entity lists as used in the paper). Requests run in a few parallel threads with retries.
import json, time
from concurrent.futures import ThreadPoolExecutor
import pandas as pd
from gomd import GOMDClient
client = GOMDClient("https://gomd.pirireis.edu.tr")
JOBS = [["ember_carbon_intensity_electricity_gco2_kwh", "ci"], ["ember_low_carbon_electricity_share_pct", "lowcarbon"], ["wb_electricity_coal_share_pct", "coal_share"], ["wb_electricity_hydro_share_pct", "hydro_share"], ["wb_electricity_nuclear_share_pct", "nuclear_share"], ["wb_gdp_current", "gdp"], ["wb_population", "pop"]]
ENTITIES = json.loads("{\"ember_carbon_intensity_electricity_gco2_kwh\": [[\"TUR\", \"Turkiye\", \"country\"], [\"AFG\", \"Afghanistan\", \"country\"], [\"ALB\", \"Albania\", \"country\"], [\"DZA\", \"Algeria\", \"country\"], [\"DEU\", \"Germany\", \"country\"], [\"ASM\", \"American Samoa\", \"country\"], [\"AGO\", \"Angola\", \"country\"], [\"ATG\", \"Antigua and Barbuda\", \"country\"], [\"ARG\", \"Argentina\", \"country\"], [\"ARM\", \"Armenia\", \"country\"], [\"ABW\", \"Aruba\", \"country\"], [\"AUS\", \"Australia\", \"country\"], [\"AUT\", \"Austria\", \"country\"], [\"EUU\", \"European Union\", \"aggregate\"], [\"AZE\", \"Azerbaijan\", \"country\"], [\"BHS\", \"Bahamas, The\", \"country\"], [\"BHR\", \"Bahrain\", \"country\"], [\"BGD\", \"Bangladesh\", \"country\"], [\"BRB\", \"Barbados\", \"country\"], [\"BLR\", \"Belarus\", \"country\"], [\"BEL\", \"Belgium\", \"country\"], [\"BLZ\", \"Belize\", \"country\"], [\"BEN\", \"Benin\", \"country\"], [\"BMU\", \"Bermuda\", \"country\"], [\"BTN\", \"Bhutan\", \"country\"], [\"BOL\", \"Bolivia\", \"country\"], [\"BIH\", \"Bosnia and Herzegovina\", \"country\"], [\"BWA\", \"Botswana\", \"country\"], [\"BRA\", \"Brazil\", \"country\"], [\"VGB\", \"British Virgin Islands\", \"country\"], [\"BRN\", \"Brunei Darussalam\", \"country\"], [\"BGR\", \"Bulgaria\", \"country\"], [\"BFA\", \"Burkina Faso\", \"country\"], [\"BDI\", \"Burundi\", \"country\"], [\"CPV\", \"Cabo Verde\", \"country\"], [\"KHM\", \"Cambodia\", \"country\"], [\"CMR\", \"Cameroon\", \"country\"], [\"CAN\", \"Canada\", \"country\"], [\"CYM\", \"Cayman Islands\", \"country\"], [\"CAF\", \"Central African Republic\", \"country\"], [\"TCD\", \"Chad\", \"country\"], [\"CHL\", \"Chile\", \"country\"], [\"TWN\", \"Chinese Taipei\", \"country\"], [\"CHN\", \"China\", \"country\"], [\"COL\", \"Colombia\", \"country\"], [\"COM\", \"Comoros\", \"country\"], [\"COG\", \"Congo, Rep.\", \"country\"], [\"COK\", \"Cook Islands\", \"country\"], [\"CRI\", \"Costa Rica\", \"country\"], [\"CIV\", \"Cote d'Ivoire\", \"country\"], [\"HRV\", \"Croatia\", \"country\"], [\"CUB\", \"Cuba\", \"country\"], [\"CYP\", \"Greek Cypriot Administration of Southern Cyprus (GCA)\", \"country\"], [\"CZE\", \"Czechia\", \"country\"], [\"COD\", \"Democratic Republic of Congo\", \"country\"], [\"DNK\", \"Denmark\", \"country\"], [\"DJI\", \"Djibouti\", \"country\"], [\"DMA\", \"Dominica\", \"country\"], [\"DOM\", \"Dominican Republic\", \"country\"], [\"WLD\", \"World (Global)\", \"aggregate\"], [\"ECU\", \"Ecuador\", \"country\"], [\"EGY\", \"Egypt\", \"country\"], [\"SLV\", \"El Salvador\", \"country\"], [\"GNQ\", \"Equatorial Guinea\", \"country\"], [\"ERI\", \"Eritrea\", \"country\"], [\"EST\", \"Estonia\", \"country\"], [\"SWZ\", \"Eswatini\", \"country\"], [\"ETH\", \"Ethiopia\", \"country\"], [\"FLK\", \"Falkland Islands (Malvinas)\", \"country\"], [\"FRO\", \"Faroe Islands\", \"country\"], [\"FJI\", \"Fiji\", \"country\"], [\"FIN\", \"Finland\", \"country\"], [\"FRA\", \"France\", \"country\"], [\"GUF\", \"French Guiana\", \"country\"], [\"PYF\", \"French Polynesia\", \"country\"], [\"GAB\", \"Gabon\", \"country\"], [\"GMB\", \"Gambia, The\", \"country\"], [\"GEO\", \"Georgia\", \"country\"], [\"GHA\", \"Ghana\", \"country\"], [\"GIB\", \"Gibraltar\", \"country\"], [\"GRL\", \"Greenland\", \"country\"], [\"GRD\", \"Grenada\", \"country\"], [\"GLP\", \"Guadeloupe\", \"country\"], [\"GUM\", \"Guam\", \"country\"], [\"GTM\", \"Guatemala\", \"country\"], [\"GIN\", \"Guinea\", \"country\"], [\"GNB\", \"Guinea-Bissau\", \"country\"], [\"GUY\", \"Guyana\", \"country\"], [\"HTI\", \"Haiti\", \"country\"], [\"HND\", \"Honduras\", \"country\"], [\"HKG\", \"Hong Kong SAR, China\", \"country\"], [\"HUN\", \"Hungary\", \"country\"], [\"ISL\", \"Iceland\", \"country\"], [\"IND\", \"India\", \"country\"], [\"IDN\", \"Indonesia\", \"country\"], [\"IRN\", \"Iran, Islamic Rep.\", \"country\"], [\"IRQ\", \"Iraq\", \"country\"], [\"IRL\", \"Ireland\", \"country\"], [\"ESP\", \"Spain\", \"country\"], [\"ISR\", \"Israel\", \"country\"], [\"ITA\", \"Italy\", \"country\"], [\"JAM\", \"Jamaica\", \"country\"], [\"JPN\", \"Japan\", \"country\"], [\"JOR\", \"Jordan\", \"country\"], [\"KAZ\", \"Kazakhstan\", \"country\"], [\"KEN\", \"Kenya\", \"country\"], [\"KIR\", \"Kiribati\", \"country\"], [\"KOR\", \"Korea Rep\", \"country\"], [\"PRK\", \"Korea, Dem. People's Rep.\", \"country\"], [\"KWT\", \"Kuwait\", \"country\"], [\"KGZ\", \"Kyrgyzstan\", \"country\"], [\"LAO\", \"Laos\", \"country\"], [\"LVA\", \"Latvia\", \"country\"], [\"LBN\", \"Lebanon\", \"country\"], [\"LSO\", \"Lesotho\", \"country\"], [\"LBR\", \"Liberia\", \"country\"], [\"LBY\", \"Libya\", \"country\"], [\"LTU\", \"Lithuania\", \"country\"], [\"LUX\", \"Luxembourg\", \"country\"], [\"MAC\", \"Macao SAR, China\", \"country\"], [\"MDG\", \"Madagascar\", \"country\"], [\"MWI\", \"Malawi\", \"country\"], [\"MYS\", \"Malaysia\", \"country\"], [\"MDV\", \"Maldives\", \"country\"], [\"MLI\", \"Mali\", \"country\"], [\"MLT\", \"Malta\", \"country\"], [\"MTQ\", \"Martinique\", \"country\"], [\"MRT\", \"Mauritania\", \"country\"], [\"MUS\", \"Mauritius\", \"country\"], [\"MEX\", \"Mexico\", \"country\"], [\"MDA\", \"Moldova\", \"country\"], [\"MNG\", \"Mongolia\", \"country\"], [\"MNE\", \"Montenegro\", \"country\"], [\"MSR\", \"Montserrat\", \"country\"], [\"MAR\", \"Morocco\", \"country\"], [\"MOZ\", \"Mozambique\", \"country\"], [\"MMR\", \"Myanmar\", \"country\"], [\"NAM\", \"Namibia\", \"country\"], [\"NRU\", \"Nauru\", \"country\"], [\"NPL\", \"Nepal\", \"country\"], [\"NLD\", \"Netherlands\", \"country\"], [\"NCL\", \"New Caledonia\", \"country\"], [\"NZL\", \"New Zealand\", \"country\"], [\"NIC\", \"Nicaragua\", \"country\"], [\"NER\", \"Niger\", \"country\"], [\"NGA\", \"Nigeria\", \"country\"], [\"MKD\", \"North Macedonia\", \"country\"], [\"NOR\", \"Norway\", \"country\"], [\"OMN\", \"Oman\", \"country\"], [\"PAK\", \"Pakistan\", \"country\"], [\"PAN\", \"Panama\", \"country\"], [\"PNG\", \"Papua New Guinea\", \"country\"], [\"PRY\", \"Paraguay\", \"country\"], [\"PER\", \"Peru\", \"country\"], [\"PHL\", \"Philippines\", \"country\"], [\"POL\", \"Poland\", \"country\"], [\"PRT\", \"Portugal\", \"country\"], [\"PRI\", \"Puerto Rico\", \"country\"], [\"QAT\", \"Qatar\", \"country\"], [\"REU\", \"R\u00e9union\", \"country\"], [\"ROU\", \"Romania\", \"country\"], [\"RUS\", \"Russian Federation\", \"country\"], [\"RWA\", \"Rwanda\", \"country\"], [\"SHN\", \"Saint Helena\", \"country\"], [\"SPM\", \"Saint Pierre and Miquelon\", \"country\"], [\"WSM\", \"Samoa\", \"country\"], [\"STP\", \"Sao Tome and Principe\", \"country\"], [\"SAU\", \"Saudi Arabia\", \"country\"], [\"SEN\", \"Senegal\", \"country\"], [\"SRB\", \"Serbia\", \"country\"], [\"SYC\", \"Seychelles\", \"country\"], [\"SLE\", \"Sierra Leone\", \"country\"], [\"SGP\", \"Singapore\", \"country\"], [\"SVK\", \"Slovakia\", \"country\"], [\"SVN\", \"Slovenia\", \"country\"], [\"SLB\", \"Solomon Islands\", \"country\"], [\"SOM\", \"Somalia\", \"country\"], [\"ZAF\", \"South Africa\", \"country\"], [\"SSD\", \"South Sudan\", \"country\"], [\"LKA\", \"Sri Lanka\", \"country\"], [\"KNA\", \"St. Kitts and Nevis\", \"country\"], [\"LCA\", \"St. Lucia\", \"country\"], [\"VCT\", \"St. Vincent and the Grenadines\", \"country\"], [\"SDN\", \"Sudan\", \"country\"], [\"SUR\", \"Suriname\", \"country\"], [\"SWE\", \"Sweden\", \"country\"], [\"CHE\", \"Switzerland\", \"country\"], [\"SYR\", \"Syrian Arab Republic\", \"country\"], [\"TJK\", \"Tajikistan\", \"country\"], [\"TZA\", \"Tanzania\", \"country\"], [\"THA\", \"Thailand\", \"country\"], [\"TLS\", \"Timor-Leste\", \"country\"], [\"TGO\", \"Togo\", \"country\"], [\"TON\", \"Tonga\", \"country\"], [\"TTO\", \"Trinidad and Tobago\", \"country\"], [\"TUN\", \"Tunisia\", \"country\"], [\"TKM\", \"Turkmenistan\", \"country\"], [\"TCA\", \"Turks and Caicos Islands\", \"country\"], [\"UGA\", \"Uganda\", \"country\"], [\"GBR\", \"UK\", \"country\"], [\"UKR\", \"Ukraine\", \"country\"], [\"ARE\", \"United Arab Emirates\", \"country\"], [\"VIR\", \"United States Virgin Islands\", \"country\"], [\"URY\", \"Uruguay\", \"country\"], [\"USA\", \"USA\", \"country\"], [\"UZB\", \"Uzbekistan\", \"country\"], [\"VUT\", \"Vanuatu\", \"country\"], [\"VEN\", \"Venezuela, RB\", \"country\"], [\"VNM\", \"Vietnam\", \"country\"], [\"PSE\", \"West Bank and Gaza\", \"country\"], [\"ESH\", \"Western Sahara\", \"country\"], [\"YEM\", \"Yemen\", \"country\"], [\"GRC\", \"Greece\", \"country\"], [\"ZMB\", \"Zambia\", \"country\"], [\"ZWE\", \"Zimbabwe\", \"country\"]], \"ember_low_carbon_electricity_share_pct\": [[\"TUR\", \"Turkiye\", \"country\"], [\"AFG\", \"Afghanistan\", \"country\"], [\"ALB\", \"Albania\", \"country\"], [\"DZA\", \"Algeria\", \"country\"], [\"DEU\", \"Germany\", \"country\"], [\"ASM\", \"American Samoa\", \"country\"], [\"AGO\", \"Angola\", \"country\"], [\"ATG\", \"Antigua and Barbuda\", \"country\"], [\"ARG\", \"Argentina\", \"country\"], [\"ARM\", \"Armenia\", \"country\"], [\"ABW\", \"Aruba\", \"country\"], [\"AUS\", \"Australia\", \"country\"], [\"AUT\", \"Austria\", \"country\"], [\"EUU\", \"European Union\", \"aggregate\"], [\"AZE\", \"Azerbaijan\", \"country\"], [\"BHS\", \"Bahamas, The\", \"country\"], [\"BHR\", \"Bahrain\", \"country\"], [\"BGD\", \"Bangladesh\", \"country\"], [\"BRB\", \"Barbados\", \"country\"], [\"BLR\", \"Belarus\", \"country\"], [\"BEL\", \"Belgium\", \"country\"], [\"BLZ\", \"Belize\", \"country\"], [\"BEN\", \"Benin\", \"country\"], [\"BMU\", \"Bermuda\", \"country\"], [\"BTN\", \"Bhutan\", \"country\"], [\"BOL\", \"Bolivia\", \"country\"], [\"BIH\", \"Bosnia and Herzegovina\", \"country\"], [\"BWA\", \"Botswana\", \"country\"], [\"BRA\", \"Brazil\", \"country\"], [\"VGB\", \"British Virgin Islands\", \"country\"], [\"BRN\", \"Brunei Darussalam\", \"country\"], [\"BGR\", \"Bulgaria\", \"country\"], [\"BFA\", \"Burkina Faso\", \"country\"], [\"BDI\", \"Burundi\", \"country\"], [\"CPV\", \"Cabo Verde\", \"country\"], [\"KHM\", \"Cambodia\", \"country\"], [\"CMR\", \"Cameroon\", \"country\"], [\"CAN\", \"Canada\", \"country\"], [\"CYM\", \"Cayman Islands\", \"country\"], [\"CAF\", \"Central African Republic\", \"country\"], [\"TCD\", \"Chad\", \"country\"], [\"CHL\", \"Chile\", \"country\"], [\"TWN\", \"Chinese Taipei\", \"country\"], [\"CHN\", \"China\", \"country\"], [\"COL\", \"Colombia\", \"country\"], [\"COM\", \"Comoros\", \"country\"], [\"COG\", \"Congo, Rep.\", \"country\"], [\"COK\", \"Cook Islands\", \"country\"], [\"CRI\", \"Costa Rica\", \"country\"], [\"CIV\", \"Cote d'Ivoire\", \"country\"], [\"HRV\", \"Croatia\", \"country\"], [\"CUB\", \"Cuba\", \"country\"], [\"CYP\", \"Greek Cypriot Administration of Southern Cyprus (GCA)\", \"country\"], [\"CZE\", \"Czechia\", \"country\"], [\"COD\", \"Democratic Republic of Congo\", \"country\"], [\"DNK\", \"Denmark\", \"country\"], [\"DJI\", \"Djibouti\", \"country\"], [\"DMA\", \"Dominica\", \"country\"], [\"DOM\", \"Dominican Republic\", \"country\"], [\"WLD\", \"World (Global)\", \"aggregate\"], [\"ECU\", \"Ecuador\", \"country\"], [\"EGY\", \"Egypt\", \"country\"], [\"SLV\", \"El Salvador\", \"country\"], [\"GNQ\", \"Equatorial Guinea\", \"country\"], [\"ERI\", \"Eritrea\", \"country\"], [\"EST\", \"Estonia\", \"country\"], [\"SWZ\", \"Eswatini\", \"country\"], [\"ETH\", \"Ethiopia\", \"country\"], [\"FLK\", \"Falkland Islands (Malvinas)\", \"country\"], [\"FRO\", \"Faroe Islands\", \"country\"], [\"FJI\", \"Fiji\", \"country\"], [\"FIN\", \"Finland\", \"country\"], [\"FRA\", \"France\", \"country\"], [\"GUF\", \"French Guiana\", \"country\"], [\"PYF\", \"French Polynesia\", \"country\"], [\"GAB\", \"Gabon\", \"country\"], [\"GMB\", \"Gambia, The\", \"country\"], [\"GEO\", \"Georgia\", \"country\"], [\"GHA\", \"Ghana\", \"country\"], [\"GIB\", \"Gibraltar\", \"country\"], [\"GRL\", \"Greenland\", \"country\"], [\"GRD\", \"Grenada\", \"country\"], [\"GLP\", \"Guadeloupe\", \"country\"], [\"GUM\", \"Guam\", \"country\"], [\"GTM\", \"Guatemala\", \"country\"], [\"GIN\", \"Guinea\", \"country\"], [\"GNB\", \"Guinea-Bissau\", \"country\"], [\"GUY\", \"Guyana\", \"country\"], [\"HTI\", \"Haiti\", \"country\"], [\"HND\", \"Honduras\", \"country\"], [\"HKG\", \"Hong Kong SAR, China\", \"country\"], [\"HUN\", \"Hungary\", \"country\"], [\"ISL\", \"Iceland\", \"country\"], [\"IND\", \"India\", \"country\"], [\"IDN\", \"Indonesia\", \"country\"], [\"IRN\", \"Iran, Islamic Rep.\", \"country\"], [\"IRQ\", \"Iraq\", \"country\"], [\"IRL\", \"Ireland\", \"country\"], [\"ESP\", \"Spain\", \"country\"], [\"ISR\", \"Israel\", \"country\"], [\"ITA\", \"Italy\", \"country\"], [\"JAM\", \"Jamaica\", \"country\"], [\"JPN\", \"Japan\", \"country\"], [\"JOR\", \"Jordan\", \"country\"], [\"KAZ\", \"Kazakhstan\", \"country\"], [\"KEN\", \"Kenya\", \"country\"], [\"KIR\", \"Kiribati\", \"country\"], [\"KOR\", \"Korea Rep\", \"country\"], [\"PRK\", \"Korea, Dem. People's Rep.\", \"country\"], [\"KWT\", \"Kuwait\", \"country\"], [\"KGZ\", \"Kyrgyzstan\", \"country\"], [\"LAO\", \"Laos\", \"country\"], [\"LVA\", \"Latvia\", \"country\"], [\"LBN\", \"Lebanon\", \"country\"], [\"LSO\", \"Lesotho\", \"country\"], [\"LBR\", \"Liberia\", \"country\"], [\"LBY\", \"Libya\", \"country\"], [\"LTU\", \"Lithuania\", \"country\"], [\"LUX\", \"Luxembourg\", \"country\"], [\"MAC\", \"Macao SAR, China\", \"country\"], [\"MDG\", \"Madagascar\", \"country\"], [\"MWI\", \"Malawi\", \"country\"], [\"MYS\", \"Malaysia\", \"country\"], [\"MDV\", \"Maldives\", \"country\"], [\"MLI\", \"Mali\", \"country\"], [\"MLT\", \"Malta\", \"country\"], [\"MTQ\", \"Martinique\", \"country\"], [\"MRT\", \"Mauritania\", \"country\"], [\"MUS\", \"Mauritius\", \"country\"], [\"MEX\", \"Mexico\", \"country\"], [\"MDA\", \"Moldova\", \"country\"], [\"MNG\", \"Mongolia\", \"country\"], [\"MNE\", \"Montenegro\", \"country\"], [\"MSR\", \"Montserrat\", \"country\"], [\"MAR\", \"Morocco\", \"country\"], [\"MOZ\", \"Mozambique\", \"country\"], [\"MMR\", \"Myanmar\", \"country\"], [\"NAM\", \"Namibia\", \"country\"], [\"NRU\", \"Nauru\", \"country\"], [\"NPL\", \"Nepal\", \"country\"], [\"NLD\", \"Netherlands\", \"country\"], [\"NCL\", \"New Caledonia\", \"country\"], [\"NZL\", \"New Zealand\", \"country\"], [\"NIC\", \"Nicaragua\", \"country\"], [\"NER\", \"Niger\", \"country\"], [\"NGA\", \"Nigeria\", \"country\"], [\"MKD\", \"North Macedonia\", \"country\"], [\"NOR\", \"Norway\", \"country\"], [\"OMN\", \"Oman\", \"country\"], [\"PAK\", \"Pakistan\", \"country\"], [\"PAN\", \"Panama\", \"country\"], [\"PNG\", \"Papua New Guinea\", \"country\"], [\"PRY\", \"Paraguay\", \"country\"], [\"PER\", \"Peru\", \"country\"], [\"PHL\", \"Philippines\", \"country\"], [\"POL\", \"Poland\", \"country\"], [\"PRT\", \"Portugal\", \"country\"], [\"PRI\", \"Puerto Rico\", \"country\"], [\"QAT\", \"Qatar\", \"country\"], [\"REU\", \"R\u00e9union\", \"country\"], [\"ROU\", \"Romania\", \"country\"], [\"RUS\", \"Russian Federation\", \"country\"], [\"RWA\", \"Rwanda\", \"country\"], [\"SHN\", \"Saint Helena\", \"country\"], [\"SPM\", \"Saint Pierre and Miquelon\", \"country\"], [\"WSM\", \"Samoa\", \"country\"], [\"STP\", \"Sao Tome and Principe\", \"country\"], [\"SAU\", \"Saudi Arabia\", \"country\"], [\"SEN\", \"Senegal\", \"country\"], [\"SRB\", \"Serbia\", \"country\"], [\"SYC\", \"Seychelles\", \"country\"], [\"SLE\", \"Sierra Leone\", \"country\"], [\"SGP\", \"Singapore\", \"country\"], [\"SVK\", \"Slovakia\", \"country\"], [\"SVN\", \"Slovenia\", \"country\"], [\"SLB\", \"Solomon Islands\", \"country\"], [\"SOM\", \"Somalia\", \"country\"], [\"ZAF\", \"South Africa\", \"country\"], [\"SSD\", \"South Sudan\", \"country\"], [\"LKA\", \"Sri Lanka\", \"country\"], [\"KNA\", \"St. Kitts and Nevis\", \"country\"], [\"LCA\", \"St. Lucia\", \"country\"], [\"VCT\", \"St. Vincent and the Grenadines\", \"country\"], [\"SDN\", \"Sudan\", \"country\"], [\"SUR\", \"Suriname\", \"country\"], [\"SWE\", \"Sweden\", \"country\"], [\"CHE\", \"Switzerland\", \"country\"], [\"SYR\", \"Syrian Arab Republic\", \"country\"], [\"TJK\", \"Tajikistan\", \"country\"], [\"TZA\", \"Tanzania\", \"country\"], [\"THA\", \"Thailand\", \"country\"], [\"TLS\", \"Timor-Leste\", \"country\"], [\"TGO\", \"Togo\", \"country\"], [\"TON\", \"Tonga\", \"country\"], [\"TTO\", \"Trinidad and Tobago\", \"country\"], [\"TUN\", \"Tunisia\", \"country\"], [\"TKM\", \"Turkmenistan\", \"country\"], [\"TCA\", \"Turks and Caicos Islands\", \"country\"], [\"UGA\", \"Uganda\", \"country\"], [\"GBR\", \"UK\", \"country\"], [\"UKR\", \"Ukraine\", \"country\"], [\"ARE\", \"United Arab Emirates\", \"country\"], [\"VIR\", \"United States Virgin Islands\", \"country\"], [\"URY\", \"Uruguay\", \"country\"], [\"USA\", \"USA\", \"country\"], [\"UZB\", \"Uzbekistan\", \"country\"], [\"VUT\", \"Vanuatu\", \"country\"], [\"VEN\", \"Venezuela, RB\", \"country\"], [\"VNM\", \"Vietnam\", \"country\"], [\"PSE\", \"West Bank and Gaza\", \"country\"], [\"ESH\", \"Western Sahara\", \"country\"], [\"YEM\", \"Yemen\", \"country\"], [\"GRC\", \"Greece\", \"country\"], [\"ZMB\", \"Zambia\", \"country\"], [\"ZWE\", \"Zimbabwe\", \"country\"]], \"wb_electricity_coal_share_pct\": [[\"TUR\", \"Turkiye\", \"country\"], [\"AFG\", \"Afghanistan\", \"country\"], [\"AFE\", \"Africa Eastern and Southern\", \"country\"], [\"AFW\", \"Africa Western and Central\", \"country\"], [\"ALB\", \"Albania\", \"country\"], [\"DZA\", \"Algeria\", \"country\"], [\"DEU\", \"Germany\", \"country\"], [\"ASM\", \"American Samoa\", \"country\"], [\"AND\", \"Andorra\", \"country\"], [\"AGO\", \"Angola\", \"country\"], [\"ATG\", \"Antigua and Barbuda\", \"country\"], [\"ARB\", \"Arab World\", \"country\"], [\"ARG\", \"Argentina\", \"country\"], [\"ARM\", \"Armenia\", \"country\"], [\"ABW\", \"Aruba\", \"country\"], [\"AUS\", \"Australia\", \"country\"], [\"AUT\", \"Austria\", \"country\"], [\"EUU\", \"European Union\", \"aggregate\"], [\"ECS\", \"Europe & Central Asia\", \"aggregate\"], [\"AZE\", \"Azerbaijan\", \"country\"], [\"BHS\", \"Bahamas, The\", \"country\"], [\"BHR\", \"Bahrain\", \"country\"], [\"BGD\", \"Bangladesh\", \"country\"], [\"BRB\", \"Barbados\", \"country\"], [\"BLR\", \"Belarus\", \"country\"], [\"BEL\", \"Belgium\", \"country\"], [\"BLZ\", \"Belize\", \"country\"], [\"BEN\", \"Benin\", \"country\"], [\"BTN\", \"Bhutan\", \"country\"], [\"BOL\", \"Bolivia\", \"country\"], [\"BIH\", \"Bosnia and Herzegovina\", \"country\"], [\"BWA\", \"Botswana\", \"country\"], [\"BRA\", \"Brazil\", \"country\"], [\"VGB\", \"British Virgin Islands\", \"country\"], [\"BRN\", \"Brunei Darussalam\", \"country\"], [\"BGR\", \"Bulgaria\", \"country\"], [\"BFA\", \"Burkina Faso\", \"country\"], [\"BDI\", \"Burundi\", \"country\"], [\"CPV\", \"Cabo Verde\", \"country\"], [\"KHM\", \"Cambodia\", \"country\"], [\"CMR\", \"Cameroon\", \"country\"], [\"CAN\", \"Canada\", \"country\"], [\"CSS\", \"Caribbean small states\", \"country\"], [\"CYM\", \"Cayman Islands\", \"country\"], [\"CAF\", \"Central African Republic\", \"country\"], [\"CEB\", \"Central Europe and the Baltics\", \"country\"], [\"TCD\", \"Chad\", \"country\"], [\"CHL\", \"Chile\", \"country\"], [\"CHN\", \"China\", \"country\"], [\"COL\", \"Colombia\", \"country\"], [\"COM\", \"Comoros\", \"country\"], [\"COG\", \"Congo, Rep.\", \"country\"], [\"CRI\", \"Costa Rica\", \"country\"], [\"CIV\", \"Cote d'Ivoire\", \"country\"], [\"HRV\", \"Croatia\", \"country\"], [\"CUB\", \"Cuba\", \"country\"], [\"CUW\", \"Curacao\", \"country\"], [\"CYP\", \"Greek Cypriot Administration of Southern Cyprus (GCA)\", \"country\"], [\"CZE\", \"Czechia\", \"country\"], [\"COD\", \"Democratic Republic of Congo\", \"country\"], [\"DNK\", \"Denmark\", \"country\"], [\"DJI\", \"Djibouti\", \"country\"], [\"EAS\", \"East Asia & Pacific\", \"aggregate\"], [\"DMA\", \"Dominica\", \"country\"], [\"DOM\", \"Dominican Republic\", \"country\"], [\"WLD\", \"World (Global)\", \"aggregate\"], [\"EAR\", \"Early-demographic dividend\", \"country\"], [\"EAP\", \"East Asia & Pacific (excluding high income)\", \"country\"], [\"TEA\", \"East Asia & Pacific (IDA & IBRD countries)\", \"country\"], [\"ECU\", \"Ecuador\", \"country\"], [\"EGY\", \"Egypt\", \"country\"], [\"SLV\", \"El Salvador\", \"country\"], [\"GNQ\", \"Equatorial Guinea\", \"country\"], [\"ERI\", \"Eritrea\", \"country\"], [\"EST\", \"Estonia\", \"country\"], [\"SWZ\", \"Eswatini\", \"country\"], [\"ETH\", \"Ethiopia\", \"country\"], [\"EMU\", \"Euro area\", \"country\"], [\"ECA\", \"Europe & Central Asia (excluding high income)\", \"country\"], [\"TEC\", \"Europe & Central Asia (IDA & IBRD countries)\", \"country\"], [\"FRO\", \"Faroe Islands\", \"country\"], [\"FJI\", \"Fiji\", \"country\"], [\"FIN\", \"Finland\", \"country\"], [\"FCV\", \"Fragility, Conflict, and Violence (FCV) situations\", \"country\"], [\"FRA\", \"France\", \"country\"], [\"PYF\", \"French Polynesia\", \"country\"], [\"GAB\", \"Gabon\", \"country\"], [\"GMB\", \"Gambia, The\", \"country\"], [\"GEO\", \"Georgia\", \"country\"], [\"GHA\", \"Ghana\", \"country\"], [\"GIB\", \"Gibraltar\", \"country\"], [\"GRL\", \"Greenland\", \"country\"], [\"GRD\", \"Grenada\", \"country\"], [\"GUM\", \"Guam\", \"country\"], [\"GTM\", \"Guatemala\", \"country\"], [\"GIN\", \"Guinea\", \"country\"], [\"GNB\", \"Guinea-Bissau\", \"country\"], [\"SAS\", \"South Asia\", \"aggregate\"], [\"GUY\", \"Guyana\", \"country\"], [\"HTI\", \"Haiti\", \"country\"], [\"HPC\", \"Heavily indebted poor countries (HIPC)\", \"country\"], [\"HND\", \"Honduras\", \"country\"], [\"HKG\", \"Hong Kong SAR, China\", \"country\"], [\"HUN\", \"Hungary\", \"country\"], [\"IBD\", \"IBRD only\", \"country\"], [\"ISL\", \"Iceland\", \"country\"], [\"IBT\", \"IDA & IBRD total\", \"country\"], [\"IDB\", \"IDA blend\", \"country\"], [\"IDX\", \"IDA only\", \"country\"], [\"IDA\", \"IDA total\", \"country\"], [\"IND\", \"India\", \"country\"], [\"IDN\", \"Indonesia\", \"country\"], [\"IRN\", \"Iran, Islamic Rep.\", \"country\"], [\"IRQ\", \"Iraq\", \"country\"], [\"IRL\", \"Ireland\", \"country\"], [\"ESP\", \"Spain\", \"country\"], [\"ISR\", \"Israel\", \"country\"], [\"ITA\", \"Italy\", \"country\"], [\"JAM\", \"Jamaica\", \"country\"], [\"JPN\", \"Japan\", \"country\"], [\"JOR\", \"Jordan\", \"country\"], [\"KAZ\", \"Kazakhstan\", \"country\"], [\"KEN\", \"Kenya\", \"country\"], [\"KIR\", \"Kiribati\", \"country\"], [\"KOR\", \"Korea Rep\", \"country\"], [\"PRK\", \"Korea, Dem. People's Rep.\", \"country\"], [\"XKX\", \"Kosovo\", \"country\"], [\"KWT\", \"Kuwait\", \"country\"], [\"NAC\", \"North America\", \"aggregate\"], [\"KGZ\", \"Kyrgyzstan\", \"country\"], [\"LAO\", \"Laos\", \"country\"], [\"LTE\", \"Late-demographic dividend\", \"country\"], [\"LAC\", \"Latin America & Caribbean (excluding high income)\", \"country\"], [\"TLA\", \"Latin America & the Caribbean (IDA & IBRD countries)\", \"country\"], [\"LCN\", \"Latin America & Caribbean\", \"aggregate\"], [\"LVA\", \"Latvia\", \"country\"], [\"LDC\", \"Least developed countries: UN classification\", \"country\"], [\"LBN\", \"Lebanon\", \"country\"], [\"LSO\", \"Lesotho\", \"country\"], [\"LBR\", \"Liberia\", \"country\"], [\"LBY\", \"Libya\", \"country\"], [\"LTU\", \"Lithuania\", \"country\"], [\"LMY\", \"Low & middle income\", \"country\"], [\"LUX\", \"Luxembourg\", \"country\"], [\"MDG\", \"Madagascar\", \"country\"], [\"MWI\", \"Malawi\", \"country\"], [\"MYS\", \"Malaysia\", \"country\"], [\"MDV\", \"Maldives\", \"country\"], [\"MLI\", \"Mali\", \"country\"], [\"MLT\", \"Malta\", \"country\"], [\"MHL\", \"Marshall Islands\", \"country\"], [\"MRT\", \"Mauritania\", \"country\"], [\"MUS\", \"Mauritius\", \"country\"], [\"MEX\", \"Mexico\", \"country\"], [\"FSM\", \"Micronesia, Fed. Sts.\", \"country\"], [\"MNA\", \"Middle East, North Africa, Afghanistan & Pakistan (excluding high income)\", \"country\"], [\"TMN\", \"Middle East, North Africa, Afghanistan & Pakistan (IDA & IBRD)\", \"country\"], [\"MIC\", \"Middle income\", \"country\"], [\"MDA\", \"Moldova\", \"country\"], [\"MNG\", \"Mongolia\", \"country\"], [\"MNE\", \"Montenegro\", \"country\"], [\"MAR\", \"Morocco\", \"country\"], [\"MOZ\", \"Mozambique\", \"country\"], [\"MMR\", \"Myanmar\", \"country\"], [\"NAM\", \"Namibia\", \"country\"], [\"NRU\", \"Nauru\", \"country\"], [\"NPL\", \"Nepal\", \"country\"], [\"NLD\", \"Netherlands\", \"country\"], [\"NCL\", \"New Caledonia\", \"country\"], [\"NZL\", \"New Zealand\", \"country\"], [\"NIC\", \"Nicaragua\", \"country\"], [\"NER\", \"Niger\", \"country\"], [\"NGA\", \"Nigeria\", \"country\"], [\"MKD\", \"North Macedonia\", \"country\"], [\"NOR\", \"Norway\", \"country\"], [\"OED\", \"OECD members\", \"aggregate\"], [\"OMN\", \"Oman\", \"country\"], [\"MEA\", \"Middle East, North Africa, Afghanistan & Pakistan\", \"aggregate\"], [\"OSS\", \"Other small states\", \"country\"], [\"PSS\", \"Pacific island small states\", \"country\"], [\"PAK\", \"Pakistan\", \"country\"], [\"PLW\", \"Palau\", \"country\"], [\"PAN\", \"Panama\", \"country\"], [\"PNG\", \"Papua New Guinea\", \"country\"], [\"PRY\", \"Paraguay\", \"country\"], [\"PER\", \"Peru\", \"country\"], [\"PHL\", \"Philippines\", \"country\"], [\"POL\", \"Poland\", \"country\"], [\"PRT\", \"Portugal\", \"country\"], [\"PST\", \"Post-demographic dividend\", \"country\"], [\"PRE\", \"Pre-demographic dividend\", \"country\"], [\"PRI\", \"Puerto Rico\", \"country\"], [\"QAT\", \"Qatar\", \"country\"], [\"ROU\", \"Romania\", \"country\"], [\"RUS\", \"Russian Federation\", \"country\"], [\"RWA\", \"Rwanda\", \"country\"], [\"SSF\", \"Sub-Saharan Africa\", \"aggregate\"], [\"WSM\", \"Samoa\", \"country\"], [\"STP\", \"Sao Tome and Principe\", \"country\"], [\"SAU\", \"Saudi Arabia\", \"country\"], [\"SEN\", \"Senegal\", \"country\"], [\"SRB\", \"Serbia\", \"country\"], [\"SYC\", \"Seychelles\", \"country\"], [\"SLE\", \"Sierra Leone\", \"country\"], [\"SGP\", \"Singapore\", \"country\"], [\"SXM\", \"Sint Maarten (Dutch part)\", \"country\"], [\"SVK\", \"Slovakia\", \"country\"], [\"SVN\", \"Slovenia\", \"country\"], [\"SST\", \"Small states\", \"country\"], [\"SLB\", \"Solomon Islands\", \"country\"], [\"SOM\", \"Somalia\", \"country\"], [\"ZAF\", \"South Africa\", \"country\"], [\"TSA\", \"South Asia (IDA & IBRD)\", \"country\"], [\"SSD\", \"South Sudan\", \"country\"], [\"LKA\", \"Sri Lanka\", \"country\"], [\"KNA\", \"St. Kitts and Nevis\", \"country\"], [\"LCA\", \"St. Lucia\", \"country\"], [\"MAF\", \"St. Martin (French part)\", \"country\"], [\"VCT\", \"St. Vincent and the Grenadines\", \"country\"], [\"SSA\", \"Sub-Saharan Africa (excluding high income)\", \"country\"], [\"TSS\", \"Sub-Saharan Africa (IDA & IBRD countries)\", \"country\"], [\"SDN\", \"Sudan\", \"country\"], [\"SUR\", \"Suriname\", \"country\"], [\"SWE\", \"Sweden\", \"country\"], [\"CHE\", \"Switzerland\", \"country\"], [\"SYR\", \"Syrian Arab Republic\", \"country\"], [\"TJK\", \"Tajikistan\", \"country\"], [\"TZA\", \"Tanzania\", \"country\"], [\"THA\", \"Thailand\", \"country\"], [\"TLS\", \"Timor-Leste\", \"country\"], [\"TGO\", \"Togo\", \"country\"], [\"TON\", \"Tonga\", \"country\"], [\"TTO\", \"Trinidad and Tobago\", \"country\"], [\"TUN\", \"Tunisia\", \"country\"], [\"TKM\", \"Turkmenistan\", \"country\"], [\"TCA\", \"Turks and Caicos Islands\", \"country\"], [\"TUV\", \"Tuvalu\", \"country\"], [\"UGA\", \"Uganda\", \"country\"], [\"GBR\", \"UK\", \"country\"], [\"UKR\", \"Ukraine\", \"country\"], [\"ARE\", \"United Arab Emirates\", \"country\"], [\"VIR\", \"United States Virgin Islands\", \"country\"], [\"URY\", \"Uruguay\", \"country\"], [\"USA\", \"USA\", \"country\"], [\"UZB\", \"Uzbekistan\", \"country\"], [\"VUT\", \"Vanuatu\", \"country\"], [\"VEN\", \"Venezuela, RB\", \"country\"], [\"VNM\", \"Vietnam\", \"country\"], [\"PSE\", \"West Bank and Gaza\", \"country\"], [\"YEM\", \"Yemen\", \"country\"], [\"GRC\", \"Greece\", \"country\"], [\"ZMB\", \"Zambia\", \"country\"], [\"ZWE\", \"Zimbabwe\", \"country\"]], \"wb_electricity_hydro_share_pct\": [[\"TUR\", \"Turkiye\", \"country\"], [\"AFG\", \"Afghanistan\", \"country\"], [\"AFE\", \"Africa Eastern and Southern\", \"country\"], [\"AFW\", \"Africa Western and Central\", \"country\"], [\"ALB\", \"Albania\", \"country\"], [\"DZA\", \"Algeria\", \"country\"], [\"DEU\", \"Germany\", \"country\"], [\"ASM\", \"American Samoa\", \"country\"], [\"AND\", \"Andorra\", \"country\"], [\"AGO\", \"Angola\", \"country\"], [\"ATG\", \"Antigua and Barbuda\", \"country\"], [\"ARB\", \"Arab World\", \"country\"], [\"ARG\", \"Argentina\", \"country\"], [\"ARM\", \"Armenia\", \"country\"], [\"ABW\", \"Aruba\", \"country\"], [\"AUS\", \"Australia\", \"country\"], [\"AUT\", \"Austria\", \"country\"], [\"EUU\", \"European Union\", \"aggregate\"], [\"ECS\", \"Europe & Central Asia\", \"aggregate\"], [\"AZE\", \"Azerbaijan\", \"country\"], [\"BHS\", \"Bahamas, The\", \"country\"], [\"BHR\", \"Bahrain\", \"country\"], [\"BGD\", \"Bangladesh\", \"country\"], [\"BRB\", \"Barbados\", \"country\"], [\"BLR\", \"Belarus\", \"country\"], [\"BEL\", \"Belgium\", \"country\"], [\"BLZ\", \"Belize\", \"country\"], [\"BEN\", \"Benin\", \"country\"], [\"BTN\", \"Bhutan\", \"country\"], [\"BOL\", \"Bolivia\", \"country\"], [\"BIH\", \"Bosnia and Herzegovina\", \"country\"], [\"BWA\", \"Botswana\", \"country\"], [\"BRA\", \"Brazil\", \"country\"], [\"VGB\", \"British Virgin Islands\", \"country\"], [\"BRN\", \"Brunei Darussalam\", \"country\"], [\"BGR\", \"Bulgaria\", \"country\"], [\"BFA\", \"Burkina Faso\", \"country\"], [\"BDI\", \"Burundi\", \"country\"], [\"CPV\", \"Cabo Verde\", \"country\"], [\"KHM\", \"Cambodia\", \"country\"], [\"CMR\", \"Cameroon\", \"country\"], [\"CAN\", \"Canada\", \"country\"], [\"CSS\", \"Caribbean small states\", \"country\"], [\"CYM\", \"Cayman Islands\", \"country\"], [\"CAF\", \"Central African Republic\", \"country\"], [\"CEB\", \"Central Europe and the Baltics\", \"country\"], [\"TCD\", \"Chad\", \"country\"], [\"CHL\", \"Chile\", \"country\"], [\"CHN\", \"China\", \"country\"], [\"COL\", \"Colombia\", \"country\"], [\"COM\", \"Comoros\", \"country\"], [\"COG\", \"Congo, Rep.\", \"country\"], [\"CRI\", \"Costa Rica\", \"country\"], [\"CIV\", \"Cote d'Ivoire\", \"country\"], [\"HRV\", \"Croatia\", \"country\"], [\"CUB\", \"Cuba\", \"country\"], [\"CUW\", \"Curacao\", \"country\"], [\"CYP\", \"Greek Cypriot Administration of Southern Cyprus (GCA)\", \"country\"], [\"CZE\", \"Czechia\", \"country\"], [\"COD\", \"Democratic Republic of Congo\", \"country\"], [\"DNK\", \"Denmark\", \"country\"], [\"DJI\", \"Djibouti\", \"country\"], [\"EAS\", \"East Asia & Pacific\", \"aggregate\"], [\"DMA\", \"Dominica\", \"country\"], [\"DOM\", \"Dominican Republic\", \"country\"], [\"WLD\", \"World (Global)\", \"aggregate\"], [\"EAR\", \"Early-demographic dividend\", \"country\"], [\"EAP\", \"East Asia & Pacific (excluding high income)\", \"country\"], [\"TEA\", \"East Asia & Pacific (IDA & IBRD countries)\", \"country\"], [\"ECU\", \"Ecuador\", \"country\"], [\"EGY\", \"Egypt\", \"country\"], [\"SLV\", \"El Salvador\", \"country\"], [\"GNQ\", \"Equatorial Guinea\", \"country\"], [\"ERI\", \"Eritrea\", \"country\"], [\"EST\", \"Estonia\", \"country\"], [\"SWZ\", \"Eswatini\", \"country\"], [\"ETH\", \"Ethiopia\", \"country\"], [\"EMU\", \"Euro area\", \"country\"], [\"ECA\", \"Europe & Central Asia (excluding high income)\", \"country\"], [\"TEC\", \"Europe & Central Asia (IDA & IBRD countries)\", \"country\"], [\"FRO\", \"Faroe Islands\", \"country\"], [\"FJI\", \"Fiji\", \"country\"], [\"FIN\", \"Finland\", \"country\"], [\"FCV\", \"Fragility, Conflict, and Violence (FCV) situations\", \"country\"], [\"FRA\", \"France\", \"country\"], [\"PYF\", \"French Polynesia\", \"country\"], [\"GAB\", \"Gabon\", \"country\"], [\"GMB\", \"Gambia, The\", \"country\"], [\"GEO\", \"Georgia\", \"country\"], [\"GHA\", \"Ghana\", \"country\"], [\"GIB\", \"Gibraltar\", \"country\"], [\"GRL\", \"Greenland\", \"country\"], [\"GRD\", \"Grenada\", \"country\"], [\"GUM\", \"Guam\", \"country\"], [\"GTM\", \"Guatemala\", \"country\"], [\"GIN\", \"Guinea\", \"country\"], [\"GNB\", \"Guinea-Bissau\", \"country\"], [\"SAS\", \"South Asia\", \"aggregate\"], [\"GUY\", \"Guyana\", \"country\"], [\"HTI\", \"Haiti\", \"country\"], [\"HPC\", \"Heavily indebted poor countries (HIPC)\", \"country\"], [\"HND\", \"Honduras\", \"country\"], [\"HKG\", \"Hong Kong SAR, China\", \"country\"], [\"HUN\", \"Hungary\", \"country\"], [\"IBD\", \"IBRD only\", \"country\"], [\"ISL\", \"Iceland\", \"country\"], [\"IBT\", \"IDA & IBRD total\", \"country\"], [\"IDB\", \"IDA blend\", \"country\"], [\"IDX\", \"IDA only\", \"country\"], [\"IDA\", \"IDA total\", \"country\"], [\"IND\", \"India\", \"country\"], [\"IDN\", \"Indonesia\", \"country\"], [\"IRN\", \"Iran, Islamic Rep.\", \"country\"], [\"IRQ\", \"Iraq\", \"country\"], [\"IRL\", \"Ireland\", \"country\"], [\"ESP\", \"Spain\", \"country\"], [\"ISR\", \"Israel\", \"country\"], [\"ITA\", \"Italy\", \"country\"], [\"JAM\", \"Jamaica\", \"country\"], [\"JPN\", \"Japan\", \"country\"], [\"JOR\", \"Jordan\", \"country\"], [\"KAZ\", \"Kazakhstan\", \"country\"], [\"KEN\", \"Kenya\", \"country\"], [\"KIR\", \"Kiribati\", \"country\"], [\"KOR\", \"Korea Rep\", \"country\"], [\"PRK\", \"Korea, Dem. People's Rep.\", \"country\"], [\"XKX\", \"Kosovo\", \"country\"], [\"KWT\", \"Kuwait\", \"country\"], [\"NAC\", \"North America\", \"aggregate\"], [\"KGZ\", \"Kyrgyzstan\", \"country\"], [\"LAO\", \"Laos\", \"country\"], [\"LTE\", \"Late-demographic dividend\", \"country\"], [\"LAC\", \"Latin America & Caribbean (excluding high income)\", \"country\"], [\"TLA\", \"Latin America & the Caribbean (IDA & IBRD countries)\", \"country\"], [\"LCN\", \"Latin America & Caribbean\", \"aggregate\"], [\"LVA\", \"Latvia\", \"country\"], [\"LDC\", \"Least developed countries: UN classification\", \"country\"], [\"LBN\", \"Lebanon\", \"country\"], [\"LSO\", \"Lesotho\", \"country\"], [\"LBR\", \"Liberia\", \"country\"], [\"LBY\", \"Libya\", \"country\"], [\"LTU\", \"Lithuania\", \"country\"], [\"LMY\", \"Low & middle income\", \"country\"], [\"LUX\", \"Luxembourg\", \"country\"], [\"MDG\", \"Madagascar\", \"country\"], [\"MWI\", \"Malawi\", \"country\"], [\"MYS\", \"Malaysia\", \"country\"], [\"MDV\", \"Maldives\", \"country\"], [\"MLI\", \"Mali\", \"country\"], [\"MLT\", \"Malta\", \"country\"], [\"MHL\", \"Marshall Islands\", \"country\"], [\"MRT\", \"Mauritania\", \"country\"], [\"MUS\", \"Mauritius\", \"country\"], [\"MEX\", \"Mexico\", \"country\"], [\"FSM\", \"Micronesia, Fed. Sts.\", \"country\"], [\"MNA\", \"Middle East, North Africa, Afghanistan & Pakistan (excluding high income)\", \"country\"], [\"TMN\", \"Middle East, North Africa, Afghanistan & Pakistan (IDA & IBRD)\", \"country\"], [\"MIC\", \"Middle income\", \"country\"], [\"MDA\", \"Moldova\", \"country\"], [\"MNG\", \"Mongolia\", \"country\"], [\"MNE\", \"Montenegro\", \"country\"], [\"MAR\", \"Morocco\", \"country\"], [\"MOZ\", \"Mozambique\", \"country\"], [\"MMR\", \"Myanmar\", \"country\"], [\"NAM\", \"Namibia\", \"country\"], [\"NRU\", \"Nauru\", \"country\"], [\"NPL\", \"Nepal\", \"country\"], [\"NLD\", \"Netherlands\", \"country\"], [\"NCL\", \"New Caledonia\", \"country\"], [\"NZL\", \"New Zealand\", \"country\"], [\"NIC\", \"Nicaragua\", \"country\"], [\"NER\", \"Niger\", \"country\"], [\"NGA\", \"Nigeria\", \"country\"], [\"MKD\", \"North Macedonia\", \"country\"], [\"NOR\", \"Norway\", \"country\"], [\"OED\", \"OECD members\", \"aggregate\"], [\"OMN\", \"Oman\", \"country\"], [\"MEA\", \"Middle East, North Africa, Afghanistan & Pakistan\", \"aggregate\"], [\"OSS\", \"Other small states\", \"country\"], [\"PSS\", \"Pacific island small states\", \"country\"], [\"PAK\", \"Pakistan\", \"country\"], [\"PLW\", \"Palau\", \"country\"], [\"PAN\", \"Panama\", \"country\"], [\"PNG\", \"Papua New Guinea\", \"country\"], [\"PRY\", \"Paraguay\", \"country\"], [\"PER\", \"Peru\", \"country\"], [\"PHL\", \"Philippines\", \"country\"], [\"POL\", \"Poland\", \"country\"], [\"PRT\", \"Portugal\", \"country\"], [\"PST\", \"Post-demographic dividend\", \"country\"], [\"PRE\", \"Pre-demographic dividend\", \"country\"], [\"PRI\", \"Puerto Rico\", \"country\"], [\"QAT\", \"Qatar\", \"country\"], [\"ROU\", \"Romania\", \"country\"], [\"RUS\", \"Russian Federation\", \"country\"], [\"RWA\", \"Rwanda\", \"country\"], [\"SSF\", \"Sub-Saharan Africa\", \"aggregate\"], [\"WSM\", \"Samoa\", \"country\"], [\"STP\", \"Sao Tome and Principe\", \"country\"], [\"SAU\", \"Saudi Arabia\", \"country\"], [\"SEN\", \"Senegal\", \"country\"], [\"SRB\", \"Serbia\", \"country\"], [\"SYC\", \"Seychelles\", \"country\"], [\"SLE\", \"Sierra Leone\", \"country\"], [\"SGP\", \"Singapore\", \"country\"], [\"SXM\", \"Sint Maarten (Dutch part)\", \"country\"], [\"SVK\", \"Slovakia\", \"country\"], [\"SVN\", \"Slovenia\", \"country\"], [\"SST\", \"Small states\", \"country\"], [\"SLB\", \"Solomon Islands\", \"country\"], [\"SOM\", \"Somalia\", \"country\"], [\"ZAF\", \"South Africa\", \"country\"], [\"TSA\", \"South Asia (IDA & IBRD)\", \"country\"], [\"SSD\", \"South Sudan\", \"country\"], [\"LKA\", \"Sri Lanka\", \"country\"], [\"KNA\", \"St. Kitts and Nevis\", \"country\"], [\"LCA\", \"St. Lucia\", \"country\"], [\"MAF\", \"St. Martin (French part)\", \"country\"], [\"VCT\", \"St. Vincent and the Grenadines\", \"country\"], [\"SSA\", \"Sub-Saharan Africa (excluding high income)\", \"country\"], [\"TSS\", \"Sub-Saharan Africa (IDA & IBRD countries)\", \"country\"], [\"SDN\", \"Sudan\", \"country\"], [\"SUR\", \"Suriname\", \"country\"], [\"SWE\", \"Sweden\", \"country\"], [\"CHE\", \"Switzerland\", \"country\"], [\"SYR\", \"Syrian Arab Republic\", \"country\"], [\"TJK\", \"Tajikistan\", \"country\"], [\"TZA\", \"Tanzania\", \"country\"], [\"THA\", \"Thailand\", \"country\"], [\"TLS\", \"Timor-Leste\", \"country\"], [\"TGO\", \"Togo\", \"country\"], [\"TON\", \"Tonga\", \"country\"], [\"TTO\", \"Trinidad and Tobago\", \"country\"], [\"TUN\", \"Tunisia\", \"country\"], [\"TKM\", \"Turkmenistan\", \"country\"], [\"TCA\", \"Turks and Caicos Islands\", \"country\"], [\"TUV\", \"Tuvalu\", \"country\"], [\"UGA\", \"Uganda\", \"country\"], [\"GBR\", \"UK\", \"country\"], [\"UKR\", \"Ukraine\", \"country\"], [\"ARE\", \"United Arab Emirates\", \"country\"], [\"VIR\", \"United States Virgin Islands\", \"country\"], [\"URY\", \"Uruguay\", \"country\"], [\"USA\", \"USA\", \"country\"], [\"UZB\", \"Uzbekistan\", \"country\"], [\"VUT\", \"Vanuatu\", \"country\"], [\"VEN\", \"Venezuela, RB\", \"country\"], [\"VNM\", \"Vietnam\", \"country\"], [\"PSE\", \"West Bank and Gaza\", \"country\"], [\"YEM\", \"Yemen\", \"country\"], [\"GRC\", \"Greece\", \"country\"], [\"ZMB\", \"Zambia\", \"country\"], [\"ZWE\", \"Zimbabwe\", \"country\"]], \"wb_electricity_nuclear_share_pct\": [[\"TUR\", \"Turkiye\", \"country\"], [\"AFG\", \"Afghanistan\", \"country\"], [\"AFE\", \"Africa Eastern and Southern\", \"country\"], [\"AFW\", \"Africa Western and Central\", \"country\"], [\"ALB\", \"Albania\", \"country\"], [\"DZA\", \"Algeria\", \"country\"], [\"DEU\", \"Germany\", \"country\"], [\"ASM\", \"American Samoa\", \"country\"], [\"AND\", \"Andorra\", \"country\"], [\"AGO\", \"Angola\", \"country\"], [\"ATG\", \"Antigua and Barbuda\", \"country\"], [\"ARB\", \"Arab World\", \"country\"], [\"ARG\", \"Argentina\", \"country\"], [\"ARM\", \"Armenia\", \"country\"], [\"ABW\", \"Aruba\", \"country\"], [\"AUS\", \"Australia\", \"country\"], [\"AUT\", \"Austria\", \"country\"], [\"EUU\", \"European Union\", \"aggregate\"], [\"ECS\", \"Europe & Central Asia\", \"aggregate\"], [\"AZE\", \"Azerbaijan\", \"country\"], [\"BHS\", \"Bahamas, The\", \"country\"], [\"BHR\", \"Bahrain\", \"country\"], [\"BGD\", \"Bangladesh\", \"country\"], [\"BRB\", \"Barbados\", \"country\"], [\"BLR\", \"Belarus\", \"country\"], [\"BEL\", \"Belgium\", \"country\"], [\"BLZ\", \"Belize\", \"country\"], [\"BEN\", \"Benin\", \"country\"], [\"BTN\", \"Bhutan\", \"country\"], [\"BOL\", \"Bolivia\", \"country\"], [\"BIH\", \"Bosnia and Herzegovina\", \"country\"], [\"BWA\", \"Botswana\", \"country\"], [\"BRA\", \"Brazil\", \"country\"], [\"VGB\", \"British Virgin Islands\", \"country\"], [\"BRN\", \"Brunei Darussalam\", \"country\"], [\"BGR\", \"Bulgaria\", \"country\"], [\"BFA\", \"Burkina Faso\", \"country\"], [\"BDI\", \"Burundi\", \"country\"], [\"CPV\", \"Cabo Verde\", \"country\"], [\"KHM\", \"Cambodia\", \"country\"], [\"CMR\", \"Cameroon\", \"country\"], [\"CAN\", \"Canada\", \"country\"], [\"CSS\", \"Caribbean small states\", \"country\"], [\"CYM\", \"Cayman Islands\", \"country\"], [\"CAF\", \"Central African Republic\", \"country\"], [\"CEB\", \"Central Europe and the Baltics\", \"country\"], [\"TCD\", \"Chad\", \"country\"], [\"CHL\", \"Chile\", \"country\"], [\"CHN\", \"China\", \"country\"], [\"COL\", \"Colombia\", \"country\"], [\"COM\", \"Comoros\", \"country\"], [\"COG\", \"Congo, Rep.\", \"country\"], [\"CRI\", \"Costa Rica\", \"country\"], [\"CIV\", \"Cote d'Ivoire\", \"country\"], [\"HRV\", \"Croatia\", \"country\"], [\"CUB\", \"Cuba\", \"country\"], [\"CUW\", \"Curacao\", \"country\"], [\"CYP\", \"Greek Cypriot Administration of Southern Cyprus (GCA)\", \"country\"], [\"CZE\", \"Czechia\", \"country\"], [\"COD\", \"Democratic Republic of Congo\", \"country\"], [\"DNK\", \"Denmark\", \"country\"], [\"DJI\", \"Djibouti\", \"country\"], [\"EAS\", \"East Asia & Pacific\", \"aggregate\"], [\"DMA\", \"Dominica\", \"country\"], [\"DOM\", \"Dominican Republic\", \"country\"], [\"WLD\", \"World (Global)\", \"aggregate\"], [\"EAR\", \"Early-demographic dividend\", \"country\"], [\"EAP\", \"East Asia & Pacific (excluding high income)\", \"country\"], [\"TEA\", \"East Asia & Pacific (IDA & IBRD countries)\", \"country\"], [\"ECU\", \"Ecuador\", \"country\"], [\"EGY\", \"Egypt\", \"country\"], [\"SLV\", \"El Salvador\", \"country\"], [\"GNQ\", \"Equatorial Guinea\", \"country\"], [\"ERI\", \"Eritrea\", \"country\"], [\"EST\", \"Estonia\", \"country\"], [\"SWZ\", \"Eswatini\", \"country\"], [\"ETH\", \"Ethiopia\", \"country\"], [\"EMU\", \"Euro area\", \"country\"], [\"ECA\", \"Europe & Central Asia (excluding high income)\", \"country\"], [\"TEC\", \"Europe & Central Asia (IDA & IBRD countries)\", \"country\"], [\"FRO\", \"Faroe Islands\", \"country\"], [\"FJI\", \"Fiji\", \"country\"], [\"FIN\", \"Finland\", \"country\"], [\"FCV\", \"Fragility, Conflict, and Violence (FCV) situations\", \"country\"], [\"FRA\", \"France\", \"country\"], [\"PYF\", \"French Polynesia\", \"country\"], [\"GAB\", \"Gabon\", \"country\"], [\"GMB\", \"Gambia, The\", \"country\"], [\"GEO\", \"Georgia\", \"country\"], [\"GHA\", \"Ghana\", \"country\"], [\"GIB\", \"Gibraltar\", \"country\"], [\"GRL\", \"Greenland\", \"country\"], [\"GRD\", \"Grenada\", \"country\"], [\"GUM\", \"Guam\", \"country\"], [\"GTM\", \"Guatemala\", \"country\"], [\"GIN\", \"Guinea\", \"country\"], [\"GNB\", \"Guinea-Bissau\", \"country\"], [\"SAS\", \"South Asia\", \"aggregate\"], [\"GUY\", \"Guyana\", \"country\"], [\"HTI\", \"Haiti\", \"country\"], [\"HPC\", \"Heavily indebted poor countries (HIPC)\", \"country\"], [\"HND\", \"Honduras\", \"country\"], [\"HKG\", \"Hong Kong SAR, China\", \"country\"], [\"HUN\", \"Hungary\", \"country\"], [\"IBD\", \"IBRD only\", \"country\"], [\"ISL\", \"Iceland\", \"country\"], [\"IBT\", \"IDA & IBRD total\", \"country\"], [\"IDB\", \"IDA blend\", \"country\"], [\"IDX\", \"IDA only\", \"country\"], [\"IDA\", \"IDA total\", \"country\"], [\"IND\", \"India\", \"country\"], [\"IDN\", \"Indonesia\", \"country\"], [\"IRN\", \"Iran, Islamic Rep.\", \"country\"], [\"IRQ\", \"Iraq\", \"country\"], [\"IRL\", \"Ireland\", \"country\"], [\"ESP\", \"Spain\", \"country\"], [\"ISR\", \"Israel\", \"country\"], [\"ITA\", \"Italy\", \"country\"], [\"JAM\", \"Jamaica\", \"country\"], [\"JPN\", \"Japan\", \"country\"], [\"JOR\", \"Jordan\", \"country\"], [\"KAZ\", \"Kazakhstan\", \"country\"], [\"KEN\", \"Kenya\", \"country\"], [\"KIR\", \"Kiribati\", \"country\"], [\"KOR\", \"Korea Rep\", \"country\"], [\"PRK\", \"Korea, Dem. People's Rep.\", \"country\"], [\"XKX\", \"Kosovo\", \"country\"], [\"KWT\", \"Kuwait\", \"country\"], [\"NAC\", \"North America\", \"aggregate\"], [\"KGZ\", \"Kyrgyzstan\", \"country\"], [\"LAO\", \"Laos\", \"country\"], [\"LTE\", \"Late-demographic dividend\", \"country\"], [\"LAC\", \"Latin America & Caribbean (excluding high income)\", \"country\"], [\"TLA\", \"Latin America & the Caribbean (IDA & IBRD countries)\", \"country\"], [\"LCN\", \"Latin America & Caribbean\", \"aggregate\"], [\"LVA\", \"Latvia\", \"country\"], [\"LDC\", \"Least developed countries: UN classification\", \"country\"], [\"LBN\", \"Lebanon\", \"country\"], [\"LSO\", \"Lesotho\", \"country\"], [\"LBR\", \"Liberia\", \"country\"], [\"LBY\", \"Libya\", \"country\"], [\"LTU\", \"Lithuania\", \"country\"], [\"LMY\", \"Low & middle income\", \"country\"], [\"LUX\", \"Luxembourg\", \"country\"], [\"MDG\", \"Madagascar\", \"country\"], [\"MWI\", \"Malawi\", \"country\"], [\"MYS\", \"Malaysia\", \"country\"], [\"MDV\", \"Maldives\", \"country\"], [\"MLI\", \"Mali\", \"country\"], [\"MLT\", \"Malta\", \"country\"], [\"MHL\", \"Marshall Islands\", \"country\"], [\"MRT\", \"Mauritania\", \"country\"], [\"MUS\", \"Mauritius\", \"country\"], [\"MEX\", \"Mexico\", \"country\"], [\"FSM\", \"Micronesia, Fed. Sts.\", \"country\"], [\"MNA\", \"Middle East, North Africa, Afghanistan & Pakistan (excluding high income)\", \"country\"], [\"TMN\", \"Middle East, North Africa, Afghanistan & Pakistan (IDA & IBRD)\", \"country\"], [\"MIC\", \"Middle income\", \"country\"], [\"MDA\", \"Moldova\", \"country\"], [\"MNG\", \"Mongolia\", \"country\"], [\"MNE\", \"Montenegro\", \"country\"], [\"MAR\", \"Morocco\", \"country\"], [\"MOZ\", \"Mozambique\", \"country\"], [\"MMR\", \"Myanmar\", \"country\"], [\"NAM\", \"Namibia\", \"country\"], [\"NRU\", \"Nauru\", \"country\"], [\"NPL\", \"Nepal\", \"country\"], [\"NLD\", \"Netherlands\", \"country\"], [\"NCL\", \"New Caledonia\", \"country\"], [\"NZL\", \"New Zealand\", \"country\"], [\"NIC\", \"Nicaragua\", \"country\"], [\"NER\", \"Niger\", \"country\"], [\"NGA\", \"Nigeria\", \"country\"], [\"MKD\", \"North Macedonia\", \"country\"], [\"NOR\", \"Norway\", \"country\"], [\"OED\", \"OECD members\", \"aggregate\"], [\"OMN\", \"Oman\", \"country\"], [\"MEA\", \"Middle East, North Africa, Afghanistan & Pakistan\", \"aggregate\"], [\"OSS\", \"Other small states\", \"country\"], [\"PSS\", \"Pacific island small states\", \"country\"], [\"PAK\", \"Pakistan\", \"country\"], [\"PLW\", \"Palau\", \"country\"], [\"PAN\", \"Panama\", \"country\"], [\"PNG\", \"Papua New Guinea\", \"country\"], [\"PRY\", \"Paraguay\", \"country\"], [\"PER\", \"Peru\", \"country\"], [\"PHL\", \"Philippines\", \"country\"], [\"POL\", \"Poland\", \"country\"], [\"PRT\", \"Portugal\", \"country\"], [\"PST\", \"Post-demographic dividend\", \"country\"], [\"PRE\", \"Pre-demographic dividend\", \"country\"], [\"PRI\", \"Puerto Rico\", \"country\"], [\"QAT\", \"Qatar\", \"country\"], [\"ROU\", \"Romania\", \"country\"], [\"RUS\", \"Russian Federation\", \"country\"], [\"RWA\", \"Rwanda\", \"country\"], [\"SSF\", \"Sub-Saharan Africa\", \"aggregate\"], [\"WSM\", \"Samoa\", \"country\"], [\"STP\", \"Sao Tome and Principe\", \"country\"], [\"SAU\", \"Saudi Arabia\", \"country\"], [\"SEN\", \"Senegal\", \"country\"], [\"SRB\", \"Serbia\", \"country\"], [\"SYC\", \"Seychelles\", \"country\"], [\"SLE\", \"Sierra Leone\", \"country\"], [\"SGP\", \"Singapore\", \"country\"], [\"SXM\", \"Sint Maarten (Dutch part)\", \"country\"], [\"SVK\", \"Slovakia\", \"country\"], [\"SVN\", \"Slovenia\", \"country\"], [\"SST\", \"Small states\", \"country\"], [\"SLB\", \"Solomon Islands\", \"country\"], [\"SOM\", \"Somalia\", \"country\"], [\"ZAF\", \"South Africa\", \"country\"], [\"TSA\", \"South Asia (IDA & IBRD)\", \"country\"], [\"SSD\", \"South Sudan\", \"country\"], [\"LKA\", \"Sri Lanka\", \"country\"], [\"KNA\", \"St. Kitts and Nevis\", \"country\"], [\"LCA\", \"St. Lucia\", \"country\"], [\"MAF\", \"St. Martin (French part)\", \"country\"], [\"VCT\", \"St. Vincent and the Grenadines\", \"country\"], [\"SSA\", \"Sub-Saharan Africa (excluding high income)\", \"country\"], [\"TSS\", \"Sub-Saharan Africa (IDA & IBRD countries)\", \"country\"], [\"SDN\", \"Sudan\", \"country\"], [\"SUR\", \"Suriname\", \"country\"], [\"SWE\", \"Sweden\", \"country\"], [\"CHE\", \"Switzerland\", \"country\"], [\"SYR\", \"Syrian Arab Republic\", \"country\"], [\"TJK\", \"Tajikistan\", \"country\"], [\"TZA\", \"Tanzania\", \"country\"], [\"THA\", \"Thailand\", \"country\"], [\"TLS\", \"Timor-Leste\", \"country\"], [\"TGO\", \"Togo\", \"country\"], [\"TON\", \"Tonga\", \"country\"], [\"TTO\", \"Trinidad and Tobago\", \"country\"], [\"TUN\", \"Tunisia\", \"country\"], [\"TKM\", \"Turkmenistan\", \"country\"], [\"TCA\", \"Turks and Caicos Islands\", \"country\"], [\"TUV\", \"Tuvalu\", \"country\"], [\"UGA\", \"Uganda\", \"country\"], [\"GBR\", \"UK\", \"country\"], [\"UKR\", \"Ukraine\", \"country\"], [\"ARE\", \"United Arab Emirates\", \"country\"], [\"VIR\", \"United States Virgin Islands\", \"country\"], [\"URY\", \"Uruguay\", \"country\"], [\"USA\", \"USA\", \"country\"], [\"UZB\", \"Uzbekistan\", \"country\"], [\"VUT\", \"Vanuatu\", \"country\"], [\"VEN\", \"Venezuela, RB\", \"country\"], [\"VNM\", \"Vietnam\", \"country\"], [\"PSE\", \"West Bank and Gaza\", \"country\"], [\"YEM\", \"Yemen\", \"country\"], [\"GRC\", \"Greece\", \"country\"], [\"ZMB\", \"Zambia\", \"country\"], [\"ZWE\", \"Zimbabwe\", \"country\"]], \"wb_gdp_current\": [[\"TUR\", \"Turkiye\", \"country\"], [\"AFG\", \"Afghanistan\", \"country\"], [\"ALB\", \"Albania\", \"country\"], [\"DZA\", \"Algeria\", \"country\"], [\"DEU\", \"Germany\", \"country\"], [\"ASM\", \"American Samoa\", \"country\"], [\"AND\", \"Andorra\", \"country\"], [\"AGO\", \"Angola\", \"country\"], [\"ATG\", \"Antigua and Barbuda\", \"country\"], [\"ARG\", \"Argentina\", \"country\"], [\"ARM\", \"Armenia\", \"country\"], [\"ABW\", \"Aruba\", \"country\"], [\"AUS\", \"Australia\", \"country\"], [\"AUT\", \"Austria\", \"country\"], [\"AZE\", \"Azerbaijan\", \"country\"], [\"BHS\", \"Bahamas, The\", \"country\"], [\"BHR\", \"Bahrain\", \"country\"], [\"BGD\", \"Bangladesh\", \"country\"], [\"BRB\", \"Barbados\", \"country\"], [\"BLR\", \"Belarus\", \"country\"], [\"BEL\", \"Belgium\", \"country\"], [\"BLZ\", \"Belize\", \"country\"], [\"BEN\", \"Benin\", \"country\"], [\"BMU\", \"Bermuda\", \"country\"], [\"BTN\", \"Bhutan\", \"country\"], [\"BOL\", \"Bolivia\", \"country\"], [\"BIH\", \"Bosnia and Herzegovina\", \"country\"], [\"BWA\", \"Botswana\", \"country\"], [\"BRA\", \"Brazil\", \"country\"], [\"BRN\", \"Brunei Darussalam\", \"country\"], [\"BGR\", \"Bulgaria\", \"country\"], [\"BFA\", \"Burkina Faso\", \"country\"], [\"BDI\", \"Burundi\", \"country\"], [\"CPV\", \"Cabo Verde\", \"country\"], [\"KHM\", \"Cambodia\", \"country\"], [\"CMR\", \"Cameroon\", \"country\"], [\"CAN\", \"Canada\", \"country\"], [\"CYM\", \"Cayman Islands\", \"country\"], [\"CAF\", \"Central African Republic\", \"country\"], [\"TCD\", \"Chad\", \"country\"], [\"CHI\", \"Channel Islands\", \"country\"], [\"CHL\", \"Chile\", \"country\"], [\"CHN\", \"China\", \"country\"], [\"COL\", \"Colombia\", \"country\"], [\"COM\", \"Comoros\", \"country\"], [\"COG\", \"Congo, Rep.\", \"country\"], [\"CRI\", \"Costa Rica\", \"country\"], [\"CIV\", \"Cote d'Ivoire\", \"country\"], [\"HRV\", \"Croatia\", \"country\"], [\"CUB\", \"Cuba\", \"country\"], [\"CUW\", \"Curacao\", \"country\"], [\"CYP\", \"Greek Cypriot Administration of Southern Cyprus (GCA)\", \"country\"], [\"CZE\", \"Czechia\", \"country\"], [\"COD\", \"Democratic Republic of Congo\", \"country\"], [\"DNK\", \"Denmark\", \"country\"], [\"DJI\", \"Djibouti\", \"country\"], [\"DMA\", \"Dominica\", \"country\"], [\"DOM\", \"Dominican Republic\", \"country\"], [\"ECU\", \"Ecuador\", \"country\"], [\"EGY\", \"Egypt\", \"country\"], [\"SLV\", \"El Salvador\", \"country\"], [\"GNQ\", \"Equatorial Guinea\", \"country\"], [\"ERI\", \"Eritrea\", \"country\"], [\"EST\", \"Estonia\", \"country\"], [\"SWZ\", \"Eswatini\", \"country\"], [\"ETH\", \"Ethiopia\", \"country\"], [\"FRO\", \"Faroe Islands\", \"country\"], [\"FJI\", \"Fiji\", \"country\"], [\"FIN\", \"Finland\", \"country\"], [\"FRA\", \"France\", \"country\"], [\"PYF\", \"French Polynesia\", \"country\"], [\"GAB\", \"Gabon\", \"country\"], [\"GMB\", \"Gambia, The\", \"country\"], [\"GEO\", \"Georgia\", \"country\"], [\"GHA\", \"Ghana\", \"country\"], [\"GRL\", \"Greenland\", \"country\"], [\"GRD\", \"Grenada\", \"country\"], [\"GUM\", \"Guam\", \"country\"], [\"GTM\", \"Guatemala\", \"country\"], [\"GIN\", \"Guinea\", \"country\"], [\"GNB\", \"Guinea-Bissau\", \"country\"], [\"GUY\", \"Guyana\", \"country\"], [\"HTI\", \"Haiti\", \"country\"], [\"HND\", \"Honduras\", \"country\"], [\"HKG\", \"Hong Kong SAR, China\", \"country\"], [\"HUN\", \"Hungary\", \"country\"], [\"ISL\", \"Iceland\", \"country\"], [\"IND\", \"India\", \"country\"], [\"IDN\", \"Indonesia\", \"country\"], [\"IRN\", \"Iran, Islamic Rep.\", \"country\"], [\"IRQ\", \"Iraq\", \"country\"], [\"IRL\", \"Ireland\", \"country\"], [\"IMN\", \"Isle of Man\", \"country\"], [\"ESP\", \"Spain\", \"country\"], [\"ISR\", \"Israel\", \"country\"], [\"ITA\", \"Italy\", \"country\"], [\"JAM\", \"Jamaica\", \"country\"], [\"JPN\", \"Japan\", \"country\"], [\"JOR\", \"Jordan\", \"country\"], [\"KAZ\", \"Kazakhstan\", \"country\"], [\"KEN\", \"Kenya\", \"country\"], [\"KIR\", \"Kiribati\", \"country\"], [\"KOR\", \"Korea Rep\", \"country\"], [\"XKX\", \"Kosovo\", \"country\"], [\"KWT\", \"Kuwait\", \"country\"], [\"KGZ\", \"Kyrgyzstan\", \"country\"], [\"LAO\", \"Laos\", \"country\"], [\"LVA\", \"Latvia\", \"country\"], [\"LBN\", \"Lebanon\", \"country\"], [\"LSO\", \"Lesotho\", \"country\"], [\"LBR\", \"Liberia\", \"country\"], [\"LBY\", \"Libya\", \"country\"], [\"LIE\", \"Liechtenstein\", \"country\"], [\"LTU\", \"Lithuania\", \"country\"], [\"LUX\", \"Luxembourg\", \"country\"], [\"MAC\", \"Macao SAR, China\", \"country\"], [\"MDG\", \"Madagascar\", \"country\"], [\"MWI\", \"Malawi\", \"country\"], [\"MYS\", \"Malaysia\", \"country\"], [\"MDV\", \"Maldives\", \"country\"], [\"MLI\", \"Mali\", \"country\"], [\"MLT\", \"Malta\", \"country\"], [\"MHL\", \"Marshall Islands\", \"country\"], [\"MRT\", \"Mauritania\", \"country\"], [\"MUS\", \"Mauritius\", \"country\"], [\"MEX\", \"Mexico\", \"country\"], [\"FSM\", \"Micronesia, Fed. Sts.\", \"country\"], [\"MDA\", \"Moldova\", \"country\"], [\"MCO\", \"Monaco\", \"country\"], [\"MNG\", \"Mongolia\", \"country\"], [\"MNE\", \"Montenegro\", \"country\"], [\"MAR\", \"Morocco\", \"country\"], [\"MOZ\", \"Mozambique\", \"country\"], [\"MMR\", \"Myanmar\", \"country\"], [\"NAM\", \"Namibia\", \"country\"], [\"NRU\", \"Nauru\", \"country\"], [\"NPL\", \"Nepal\", \"country\"], [\"NLD\", \"Netherlands\", \"country\"], [\"NCL\", \"New Caledonia\", \"country\"], [\"NZL\", \"New Zealand\", \"country\"], [\"NIC\", \"Nicaragua\", \"country\"], [\"NER\", \"Niger\", \"country\"], [\"NGA\", \"Nigeria\", \"country\"], [\"MKD\", \"North Macedonia\", \"country\"], [\"MNP\", \"Northern Mariana Islands\", \"country\"], [\"NOR\", \"Norway\", \"country\"], [\"OMN\", \"Oman\", \"country\"], [\"PAK\", \"Pakistan\", \"country\"], [\"PLW\", \"Palau\", \"country\"], [\"PAN\", \"Panama\", \"country\"], [\"PNG\", \"Papua New Guinea\", \"country\"], [\"PRY\", \"Paraguay\", \"country\"], [\"PER\", \"Peru\", \"country\"], [\"PHL\", \"Philippines\", \"country\"], [\"POL\", \"Poland\", \"country\"], [\"PRT\", \"Portugal\", \"country\"], [\"PRI\", \"Puerto Rico\", \"country\"], [\"QAT\", \"Qatar\", \"country\"], [\"ROU\", \"Romania\", \"country\"], [\"RUS\", \"Russian Federation\", \"country\"], [\"RWA\", \"Rwanda\", \"country\"], [\"WSM\", \"Samoa\", \"country\"], [\"SMR\", \"San Marino\", \"country\"], [\"STP\", \"Sao Tome and Principe\", \"country\"], [\"SAU\", \"Saudi Arabia\", \"country\"], [\"SEN\", \"Senegal\", \"country\"], [\"SRB\", \"Serbia\", \"country\"], [\"SYC\", \"Seychelles\", \"country\"], [\"SLE\", \"Sierra Leone\", \"country\"], [\"SGP\", \"Singapore\", \"country\"], [\"SXM\", \"Sint Maarten (Dutch part)\", \"country\"], [\"SVK\", \"Slovakia\", \"country\"], [\"SVN\", \"Slovenia\", \"country\"], [\"SLB\", \"Solomon Islands\", \"country\"], [\"SOM\", \"Somalia\", \"country\"], [\"ZAF\", \"South Africa\", \"country\"], [\"SSD\", \"South Sudan\", \"country\"], [\"LKA\", \"Sri Lanka\", \"country\"], [\"KNA\", \"St. Kitts and Nevis\", \"country\"], [\"LCA\", \"St. Lucia\", \"country\"], [\"MAF\", \"St. Martin (French part)\", \"country\"], [\"VCT\", \"St. Vincent and the Grenadines\", \"country\"], [\"SDN\", \"Sudan\", \"country\"], [\"SUR\", \"Suriname\", \"country\"], [\"SWE\", \"Sweden\", \"country\"], [\"CHE\", \"Switzerland\", \"country\"], [\"SYR\", \"Syrian Arab Republic\", \"country\"], [\"TJK\", \"Tajikistan\", \"country\"], [\"TZA\", \"Tanzania\", \"country\"], [\"THA\", \"Thailand\", \"country\"], [\"TLS\", \"Timor-Leste\", \"country\"], [\"TGO\", \"Togo\", \"country\"], [\"TON\", \"Tonga\", \"country\"], [\"TTO\", \"Trinidad and Tobago\", \"country\"], [\"TUN\", \"Tunisia\", \"country\"], [\"TKM\", \"Turkmenistan\", \"country\"], [\"TCA\", \"Turks and Caicos Islands\", \"country\"], [\"TUV\", \"Tuvalu\", \"country\"], [\"UGA\", \"Uganda\", \"country\"], [\"GBR\", \"UK\", \"country\"], [\"UKR\", \"Ukraine\", \"country\"], [\"ARE\", \"United Arab Emirates\", \"country\"], [\"VIR\", \"United States Virgin Islands\", \"country\"], [\"URY\", \"Uruguay\", \"country\"], [\"USA\", \"USA\", \"country\"], [\"UZB\", \"Uzbekistan\", \"country\"], [\"VUT\", \"Vanuatu\", \"country\"], [\"VEN\", \"Venezuela, RB\", \"country\"], [\"VNM\", \"Vietnam\", \"country\"], [\"PSE\", \"West Bank and Gaza\", \"country\"], [\"YEM\", \"Yemen\", \"country\"], [\"GRC\", \"Greece\", \"country\"], [\"ZMB\", \"Zambia\", \"country\"], [\"ZWE\", \"Zimbabwe\", \"country\"]], \"wb_population\": [[\"TUR\", \"Turkiye\", \"country\"], [\"AFG\", \"Afghanistan\", \"country\"], [\"ALB\", \"Albania\", \"country\"], [\"DZA\", \"Algeria\", \"country\"], [\"DEU\", \"Germany\", \"country\"], [\"ASM\", \"American Samoa\", \"country\"], [\"AND\", \"Andorra\", \"country\"], [\"AGO\", \"Angola\", \"country\"], [\"ATG\", \"Antigua and Barbuda\", \"country\"], [\"ARG\", \"Argentina\", \"country\"], [\"ARM\", \"Armenia\", \"country\"], [\"ABW\", \"Aruba\", \"country\"], [\"AUS\", \"Australia\", \"country\"], [\"AUT\", \"Austria\", \"country\"], [\"AZE\", \"Azerbaijan\", \"country\"], [\"BHS\", \"Bahamas, The\", \"country\"], [\"BHR\", \"Bahrain\", \"country\"], [\"BGD\", \"Bangladesh\", \"country\"], [\"BRB\", \"Barbados\", \"country\"], [\"BLR\", \"Belarus\", \"country\"], [\"BEL\", \"Belgium\", \"country\"], [\"BLZ\", \"Belize\", \"country\"], [\"BEN\", \"Benin\", \"country\"], [\"BMU\", \"Bermuda\", \"country\"], [\"BTN\", \"Bhutan\", \"country\"], [\"BOL\", \"Bolivia\", \"country\"], [\"BIH\", \"Bosnia and Herzegovina\", \"country\"], [\"BWA\", \"Botswana\", \"country\"], [\"BRA\", \"Brazil\", \"country\"], [\"VGB\", \"British Virgin Islands\", \"country\"], [\"BRN\", \"Brunei Darussalam\", \"country\"], [\"BGR\", \"Bulgaria\", \"country\"], [\"BFA\", \"Burkina Faso\", \"country\"], [\"BDI\", \"Burundi\", \"country\"], [\"CPV\", \"Cabo Verde\", \"country\"], [\"KHM\", \"Cambodia\", \"country\"], [\"CMR\", \"Cameroon\", \"country\"], [\"CAN\", \"Canada\", \"country\"], [\"CYM\", \"Cayman Islands\", \"country\"], [\"CAF\", \"Central African Republic\", \"country\"], [\"TCD\", \"Chad\", \"country\"], [\"CHI\", \"Channel Islands\", \"country\"], [\"CHL\", \"Chile\", \"country\"], [\"CHN\", \"China\", \"country\"], [\"COL\", \"Colombia\", \"country\"], [\"COM\", \"Comoros\", \"country\"], [\"COG\", \"Congo, Rep.\", \"country\"], [\"CRI\", \"Costa Rica\", \"country\"], [\"CIV\", \"Cote d'Ivoire\", \"country\"], [\"HRV\", \"Croatia\", \"country\"], [\"CUB\", \"Cuba\", \"country\"], [\"CUW\", \"Curacao\", \"country\"], [\"CYP\", \"Greek Cypriot Administration of Southern Cyprus (GCA)\", \"country\"], [\"CZE\", \"Czechia\", \"country\"], [\"COD\", \"Democratic Republic of Congo\", \"country\"], [\"DNK\", \"Denmark\", \"country\"], [\"DJI\", \"Djibouti\", \"country\"], [\"DMA\", \"Dominica\", \"country\"], [\"DOM\", \"Dominican Republic\", \"country\"], [\"ECU\", \"Ecuador\", \"country\"], [\"EGY\", \"Egypt\", \"country\"], [\"SLV\", \"El Salvador\", \"country\"], [\"GNQ\", \"Equatorial Guinea\", \"country\"], [\"ERI\", \"Eritrea\", \"country\"], [\"EST\", \"Estonia\", \"country\"], [\"SWZ\", \"Eswatini\", \"country\"], [\"ETH\", \"Ethiopia\", \"country\"], [\"FRO\", \"Faroe Islands\", \"country\"], [\"FJI\", \"Fiji\", \"country\"], [\"FIN\", \"Finland\", \"country\"], [\"FRA\", \"France\", \"country\"], [\"PYF\", \"French Polynesia\", \"country\"], [\"GAB\", \"Gabon\", \"country\"], [\"GMB\", \"Gambia, The\", \"country\"], [\"GEO\", \"Georgia\", \"country\"], [\"GHA\", \"Ghana\", \"country\"], [\"GIB\", \"Gibraltar\", \"country\"], [\"GRL\", \"Greenland\", \"country\"], [\"GRD\", \"Grenada\", \"country\"], [\"GUM\", \"Guam\", \"country\"], [\"GTM\", \"Guatemala\", \"country\"], [\"GIN\", \"Guinea\", \"country\"], [\"GNB\", \"Guinea-Bissau\", \"country\"], [\"GUY\", \"Guyana\", \"country\"], [\"HTI\", \"Haiti\", \"country\"], [\"HND\", \"Honduras\", \"country\"], [\"HKG\", \"Hong Kong SAR, China\", \"country\"], [\"HUN\", \"Hungary\", \"country\"], [\"ISL\", \"Iceland\", \"country\"], [\"IND\", \"India\", \"country\"], [\"IDN\", \"Indonesia\", \"country\"], [\"IRN\", \"Iran, Islamic Rep.\", \"country\"], [\"IRQ\", \"Iraq\", \"country\"], [\"IRL\", \"Ireland\", \"country\"], [\"IMN\", \"Isle of Man\", \"country\"], [\"ESP\", \"Spain\", \"country\"], [\"ISR\", \"Israel\", \"country\"], [\"ITA\", \"Italy\", \"country\"], [\"JAM\", \"Jamaica\", \"country\"], [\"JPN\", \"Japan\", \"country\"], [\"JOR\", \"Jordan\", \"country\"], [\"KAZ\", \"Kazakhstan\", \"country\"], [\"KEN\", \"Kenya\", \"country\"], [\"KIR\", \"Kiribati\", \"country\"], [\"KOR\", \"Korea Rep\", \"country\"], [\"PRK\", \"Korea, Dem. People's Rep.\", \"country\"], [\"XKX\", \"Kosovo\", \"country\"], [\"KWT\", \"Kuwait\", \"country\"], [\"KGZ\", \"Kyrgyzstan\", \"country\"], [\"LAO\", \"Laos\", \"country\"], [\"LVA\", \"Latvia\", \"country\"], [\"LBN\", \"Lebanon\", \"country\"], [\"LSO\", \"Lesotho\", \"country\"], [\"LBR\", \"Liberia\", \"country\"], [\"LBY\", \"Libya\", \"country\"], [\"LIE\", \"Liechtenstein\", \"country\"], [\"LTU\", \"Lithuania\", \"country\"], [\"LUX\", \"Luxembourg\", \"country\"], [\"MAC\", \"Macao SAR, China\", \"country\"], [\"MDG\", \"Madagascar\", \"country\"], [\"MWI\", \"Malawi\", \"country\"], [\"MYS\", \"Malaysia\", \"country\"], [\"MDV\", \"Maldives\", \"country\"], [\"MLI\", \"Mali\", \"country\"], [\"MLT\", \"Malta\", \"country\"], [\"MHL\", \"Marshall Islands\", \"country\"], [\"MRT\", \"Mauritania\", \"country\"], [\"MUS\", \"Mauritius\", \"country\"], [\"MEX\", \"Mexico\", \"country\"], [\"FSM\", \"Micronesia, Fed. Sts.\", \"country\"], [\"MDA\", \"Moldova\", \"country\"], [\"MCO\", \"Monaco\", \"country\"], [\"MNG\", \"Mongolia\", \"country\"], [\"MNE\", \"Montenegro\", \"country\"], [\"MAR\", \"Morocco\", \"country\"], [\"MOZ\", \"Mozambique\", \"country\"], [\"MMR\", \"Myanmar\", \"country\"], [\"NAM\", \"Namibia\", \"country\"], [\"NRU\", \"Nauru\", \"country\"], [\"NPL\", \"Nepal\", \"country\"], [\"NLD\", \"Netherlands\", \"country\"], [\"NCL\", \"New Caledonia\", \"country\"], [\"NZL\", \"New Zealand\", \"country\"], [\"NIC\", \"Nicaragua\", \"country\"], [\"NER\", \"Niger\", \"country\"], [\"NGA\", \"Nigeria\", \"country\"], [\"MKD\", \"North Macedonia\", \"country\"], [\"MNP\", \"Northern Mariana Islands\", \"country\"], [\"NOR\", \"Norway\", \"country\"], [\"OMN\", \"Oman\", \"country\"], [\"PAK\", \"Pakistan\", \"country\"], [\"PLW\", \"Palau\", \"country\"], [\"PAN\", \"Panama\", \"country\"], [\"PNG\", \"Papua New Guinea\", \"country\"], [\"PRY\", \"Paraguay\", \"country\"], [\"PER\", \"Peru\", \"country\"], [\"PHL\", \"Philippines\", \"country\"], [\"POL\", \"Poland\", \"country\"], [\"PRT\", \"Portugal\", \"country\"], [\"PRI\", \"Puerto Rico\", \"country\"], [\"QAT\", \"Qatar\", \"country\"], [\"ROU\", \"Romania\", \"country\"], [\"RUS\", \"Russian Federation\", \"country\"], [\"RWA\", \"Rwanda\", \"country\"], [\"WSM\", \"Samoa\", \"country\"], [\"SMR\", \"San Marino\", \"country\"], [\"STP\", \"Sao Tome and Principe\", \"country\"], [\"SAU\", \"Saudi Arabia\", \"country\"], [\"SEN\", \"Senegal\", \"country\"], [\"SRB\", \"Serbia\", \"country\"], [\"SYC\", \"Seychelles\", \"country\"], [\"SLE\", \"Sierra Leone\", \"country\"], [\"SGP\", \"Singapore\", \"country\"], [\"SXM\", \"Sint Maarten (Dutch part)\", \"country\"], [\"SVK\", \"Slovakia\", \"country\"], [\"SVN\", \"Slovenia\", \"country\"], [\"SLB\", \"Solomon Islands\", \"country\"], [\"SOM\", \"Somalia\", \"country\"], [\"ZAF\", \"South Africa\", \"country\"], [\"SSD\", \"South Sudan\", \"country\"], [\"LKA\", \"Sri Lanka\", \"country\"], [\"KNA\", \"St. Kitts and Nevis\", \"country\"], [\"LCA\", \"St. Lucia\", \"country\"], [\"MAF\", \"St. Martin (French part)\", \"country\"], [\"VCT\", \"St. Vincent and the Grenadines\", \"country\"], [\"SDN\", \"Sudan\", \"country\"], [\"SUR\", \"Suriname\", \"country\"], [\"SWE\", \"Sweden\", \"country\"], [\"CHE\", \"Switzerland\", \"country\"], [\"SYR\", \"Syrian Arab Republic\", \"country\"], [\"TJK\", \"Tajikistan\", \"country\"], [\"TZA\", \"Tanzania\", \"country\"], [\"THA\", \"Thailand\", \"country\"], [\"TLS\", \"Timor-Leste\", \"country\"], [\"TGO\", \"Togo\", \"country\"], [\"TON\", \"Tonga\", \"country\"], [\"TTO\", \"Trinidad and Tobago\", \"country\"], [\"TUN\", \"Tunisia\", \"country\"], [\"TKM\", \"Turkmenistan\", \"country\"], [\"TCA\", \"Turks and Caicos Islands\", \"country\"], [\"TUV\", \"Tuvalu\", \"country\"], [\"UGA\", \"Uganda\", \"country\"], [\"GBR\", \"UK\", \"country\"], [\"UKR\", \"Ukraine\", \"country\"], [\"ARE\", \"United Arab Emirates\", \"country\"], [\"VIR\", \"United States Virgin Islands\", \"country\"], [\"URY\", \"Uruguay\", \"country\"], [\"USA\", \"USA\", \"country\"], [\"UZB\", \"Uzbekistan\", \"country\"], [\"VUT\", \"Vanuatu\", \"country\"], [\"VEN\", \"Venezuela, RB\", \"country\"], [\"VNM\", \"Vietnam\", \"country\"], [\"PSE\", \"West Bank and Gaza\", \"country\"], [\"YEM\", \"Yemen\", \"country\"], [\"GRC\", \"Greece\", \"country\"], [\"ZMB\", \"Zambia\", \"country\"], [\"ZWE\", \"Zimbabwe\", \"country\"]]}")
CAP = {}

def fetch(indicator, entity, retries=6):
    for k in range(retries):
        try:
            rows = client.get_series(indicator=indicator, entity=entity, limit=50000, as_df=False)
            return [(str(r["period"]), float(r["value"])) for r in rows if str(r.get("entity_code") or "") == entity and r.get("value") is not None]
        except Exception as e:
            if k == retries - 1: raise
            time.sleep(2 ** k)

def fetch_panel(indicator, out_csv):
    ents = ENTITIES[indicator]
    with ThreadPoolExecutor(max_workers=4) as ex:
        res = list(ex.map(lambda e: fetch(indicator, e[0]), ents))
    recs = [(c, n, t, p, v) for (c, n, t), rows in zip(ents, res) for p, v in rows]
    df = pd.DataFrame(recs, columns=["entity", "name", "etype", "period", "value"]).drop_duplicates(["entity", "period"])
    if indicator in CAP: df = df[df.period <= CAP[indicator]]
    df.to_csv(out_csv, index=False)
    return df

if VERI_KAYNAGI == "api":
    for ind, f in JOBS:
        t = time.time(); df = fetch_panel(ind, f"data/{f}.csv")
        print(f"{f:28s} {len(df):7d} rows  {df.entity.nunique():4d} entities  {df.period.min()}-{df.period.max()}  ({time.time() - t:.0f} s)")

# ## 2. Phillips–Sul log t testi, kulüpler, sağlamlık, sıralı logit ve ısı pompası örneği

# Paper 3: Phillips-Sul club convergence of the carbon intensity of electricity, 2000-2024, and determinants of club membership.
import json, warnings
import numpy as np, pandas as pd
import statsmodels.api as sm
from statsmodels.tsa.filters.hp_filter import hpfilter
from statsmodels.miscmodels.ordinal_model import OrderedModel
from sklearn.metrics import adjusted_rand_score
import matplotlib
import matplotlib.pyplot as plt
warnings.filterwarnings("ignore")
plt.rcParams.update({"font.family": "DejaVu Serif", "font.size": 9, "axes.titlesize": 10, "legend.fontsize": 8,
                     "savefig.dpi": 300, "axes.spines.top": False, "axes.spines.right": False})
R = {}
Y0, Y1 = 2000, 2024

def panel(name, etype="country"):
    d = pd.read_csv(f"data/{name}.csv", dtype={"period": str})
    d = d[d.etype == etype].copy(); d["year"] = d.period.str[:4].astype(int)
    return d.pivot_table(index="year", columns="entity", values="value")
CI = panel("ci").loc[Y0:Y1]
CI = CI.dropna(axis=1)
CI = CI.loc[:, (CI > 1).all()]            # log t requires log(CI) > 0
names = pd.read_csv("data/ci.csv")[["entity", "name"]].drop_duplicates("entity").set_index("entity").name
N, T = CI.shape[1], CI.shape[0]
R["N"], R["T"], R["years"] = int(N), int(T), [Y0, Y1]

def trend(X, lam):
    return pd.DataFrame({c: hpfilter(np.log(X[c].values), lamb=lam)[1] for c in X.columns}, index=X.index)

def logt(G, r=0.3):
    """Phillips-Sul log t regression on trend components G (T x n). Returns (b, t_b)."""
    g = G.values; h = g / g.mean(axis=1, keepdims=True)
    H = ((h - 1) ** 2).mean(axis=1)
    TT = len(H); t = np.arange(1, TT + 1)
    s = max(int(np.floor(r * TT)), 2)
    yv = np.log(H[0] / H[s - 1:]) - 2 * np.log(np.log(t[s - 1:]))
    X = sm.add_constant(np.log(t[s - 1:]))
    n = len(yv); lag = int(np.floor(4 * (n / 100) ** (2 / 9)))
    m = sm.OLS(yv, X).fit(cov_type="HAC", cov_kwds={"maxlags": lag})
    return float(m.params[1]), float(m.tvalues[1])

def clubs(G, r=0.3, crit=-1.65, merge="vLT"):
    """Phillips & Sul (2007) clustering with the sieve criterion c* = 0, followed by Phillips & Sul (2009) merging."""
    order = list(G.iloc[-1].sort_values(ascending=False).index)
    out, rest = [], order[:]
    while len(rest) >= 2:
        # core group: first adjacent pair that converges, then grow while converging; keep size with max t
        start = None
        for i in range(len(rest) - 1):
            if logt(G[rest[i:i + 2]], r)[1] > crit:
                start = i; break
        if start is None:
            break
        best_k, best_t, k = 2, logt(G[rest[start:start + 2]], r)[1], 2
        while start + k < len(rest):
            tk = logt(G[rest[start:start + k + 1]], r)[1]
            if tk <= crit: break
            k += 1
            if tk > best_t: best_k, best_t = k, tk
        core = rest[start:start + best_k]
        others = [u for u in rest if u not in core]
        c = 0.0
        while True:
            add = [u for u in others if logt(G[core + [u]], r)[1] > c]
            club = core + add
            if logt(G[club], r)[1] > crit or not add:
                break
            c += 0.05
        out.append([u for u in order if u in club])
        rest = [u for u in rest if u not in club]
        if len(rest) >= 2 and logt(G[rest], r)[1] > crit:
            out.append(rest[:]); rest = []
    divergent = rest[:]
    global PRE_MERGE
    PRE_MERGE = [c[:] for c in out]
    if merge == "PS":   # Phillips & Sul (2009): merge the first adjacent pair whose union converges, repeat
        merged = True
        while merged and len(out) > 1:
            merged = False
            for i in range(len(out) - 1):
                if logt(G[out[i] + out[i + 1]], r)[1] > crit:
                    out[i] = out[i] + out[i + 1]; del out[i + 1]; merged = True; break
    elif merge == "vLT":  # von Lyncker & Thoennessen (2017): merge pair m if t(m) > -1.65 and t(m) > t(m+1)
        while len(out) > 1:
            tt = [logt(G[out[m] + out[m + 1]], r)[1] for m in range(len(out) - 1)]
            hit = None
            for m in range(len(tt)):
                if tt[m] > crit and (m == len(tt) - 1 or tt[m] > tt[m + 1]):
                    hit = m; break
            if hit is None: break
            out[hit] = out[hit] + out[hit + 1]; del out[hit + 1]
    return out, divergent

G = trend(CI, 400)
b, tb = logt(G)
R["full_panel"] = {"b": round(b, 4), "t": round(tb, 3), "converges": bool(tb > -1.65)}
initial, divergent = clubs(G)
ps_cl, _ = clubs(G, merge="PS")
R["ps_merge"] = [{"n": len(c), "t": round(logt(G[c])[1], 3), "mean_ci_2024": round(float(CI[c].iloc[-1].mean()), 1)} for c in sorted(ps_cl, key=lambda c: CI[c].iloc[-1].mean())]
pre = sorted(PRE_MERGE, key=lambda cl: CI[cl].iloc[-1].mean())
R["pre_merge"] = [{"n": len(cl), "t": round(logt(G[cl])[1], 3), "b": round(logt(G[cl])[0], 4), "mean_ci_2024": round(float(CI[cl].iloc[-1].mean()), 1), "members": cl} for cl in pre]
R["pre_merge_adjacent"] = [round(logt(G[pre[k] + pre[k + 1]])[1], 3) for k in range(len(pre) - 1)]
# relabel clubs from lowest to highest mean intensity in the final year
initial = sorted(initial, key=lambda cl: CI[cl].iloc[-1].mean())
R["clubs"] = []
for k, cl in enumerate(initial, 1):
    bb, tt = logt(G[cl])
    R["clubs"].append({"club": k, "n": len(cl), "b": round(bb, 4), "t": round(tt, 3),
                       "mean_ci_2000": round(float(CI[cl].iloc[0].mean()), 1), "mean_ci_2024": round(float(CI[cl].iloc[-1].mean()), 1),
                       "median_ci_2024": round(float(CI[cl].iloc[-1].median()), 1),
                       "pct_change": round(float((CI[cl].iloc[-1].mean() / CI[cl].iloc[0].mean() - 1) * 100), 1),
                       "members": cl})
R["divergent"] = divergent
memb = {u: k for k, cl in enumerate(initial, 1) for u in cl}
memb.update({u: 0 for u in divergent})
R["turkiye_club"] = memb.get("TUR")
# merging tests between adjacent final clubs (all should fail)
R["adjacent_tests"] = [{"clubs": f"{k}+{k + 1}", "t": round(logt(G[initial[k - 1] + initial[k]])[1], 3)} for k in range(1, len(initial))]

# ---------------- robustness: lambda and r ----------------
base_lab = pd.Series(memb)
rob = {}
for lam in (100, 400, 1600):
    for r in (0.2, 0.3, 0.4):
        if lam == 400 and r == 0.3: continue
        Gx = trend(CI, lam); cl, dv = clubs(Gx, r)
        lab = pd.Series({u: k for k, c in enumerate(sorted(cl, key=lambda c: CI[c].iloc[-1].mean()), 1) for u in c} | {u: 0 for u in dv})
        rob[f"lambda={lam}, r={r}"] = {"n_clubs": len(cl), "n_divergent": len(dv), "sizes": sorted(len(c) for c in cl), "ARI": round(float(adjusted_rand_score(base_lab[CI.columns], lab[CI.columns])), 3)}
for (a, z) in ((2005, 2024), (2000, 2019)):
    Cx = CI.loc[a:z]; Gx = trend(Cx, 400); cl, dv = clubs(Gx, 0.3)
    lab = pd.Series({u: k for k, c in enumerate(sorted(cl, key=lambda c: Cx[c].iloc[-1].mean()), 1) for u in c} | {u: 0 for u in dv})
    rob[f"sample {a}-{z}"] = {"n_clubs": len(cl), "n_divergent": len(dv), "sizes": sorted(len(c) for c in cl), "ARI": round(float(adjusted_rand_score(base_lab[CI.columns], lab[CI.columns])), 3)}
popx = panel("pop")
subsets = {"excl. series with <= 5 distinct values": [c for c in CI.columns if CI[c].nunique() > 5],
           "excl. population < 1 million (2000)": [c for c in CI.columns if c in popx.columns and popx.loc[2000, c] >= 1e6]}
for lab_, cols_ in subsets.items():
    Cx = CI[cols_]; Gx = trend(Cx, 400); cl, dv = clubs(Gx, 0.3)
    lab = pd.Series({u: k for k, c in enumerate(sorted(cl, key=lambda c: Cx[c].iloc[-1].mean()), 1) for u in c} | {u: 0 for u in dv})
    rob[lab_] = {"N": len(cols_), "n_clubs": len(cl), "n_divergent": len(dv), "sizes": sorted(len(c) for c in cl), "ARI": round(float(adjusted_rand_score(base_lab[cols_], lab[cols_])), 3)}
R["robustness"] = rob

# ---------------- determinants of club membership (ordered logit) ----------------
gdp = panel("gdp"); pop = panel("pop"); coal = panel("coal_share"); hyd = panel("hydro_share"); nuc = panel("nuclear_share")
def v(P, c, years=(2000, 2001, 2002)):
    try: return float(P.loc[list(years), c].mean())
    except Exception: return np.nan
rows = []
for c in CI.columns:
    if memb.get(c, 0) == 0: continue
    gp = v(gdp, c) / v(pop, c) if v(pop, c) else np.nan
    rows.append((c, memb[c], np.log(gp) if gp and gp > 0 else np.nan, v(coal, c), v(hyd, c), v(nuc, c), np.log(CI[c].iloc[0])))
D = pd.DataFrame(rows, columns=["iso", "club", "log_gdppc_2000", "coal_2000", "hydro_2000", "nuclear_2000", "log_ci_2000"])
D["nuclear_2000"] = D.nuclear_2000.fillna(0)
D = D.dropna()
X = D[["log_gdppc_2000", "coal_2000", "hydro_2000", "nuclear_2000"]]
om = OrderedModel(D.club, X, distr="logit").fit(method="bfgs", disp=False, maxiter=2000)
R["ologit"] = {"n": int(len(D)), "coef": {k: round(float(om.params[k]), 4) for k in X.columns}, "se": {k: round(float(om.bse[k]), 4) for k in X.columns},
               "p": {k: float(om.pvalues[k]) for k in X.columns}, "llf": round(float(om.llf), 2)}
nk = D.club.value_counts().values; llf0 = float((nk * np.log(nk / nk.sum())).sum())   # thresholds-only model
R["ologit"]["llf0"] = round(llf0, 2); R["ologit"]["mcfadden_r2"] = round(float(1 - om.llf / llf0), 3)
R["ologit"]["lr_chi2"] = round(float(2 * (om.llf - llf0)), 2)
R["ologit"]["n_by_club"] = D.club.value_counts().sort_index().to_dict()
# average marginal effects on Pr(highest-intensity club) by numerical derivative
P0 = om.predict(X.values); top = P0.shape[1] - 1
ame = {}
for j, k in enumerate(X.columns):
    h = 1e-4 * max(1.0, float(X[k].std())); X1 = X.values.copy(); X1[:, j] += h
    ame[k] = round(float(((om.predict(X1)[:, top] - P0[:, top]) / h).mean()), 5)
R["ologit"]["ame_top_club"] = ame
pred = P0.argmax(axis=1) + D.club.min()
R["ologit"]["hit_rate"] = round(float((pred == D.club.values).mean()), 3)
R["ologit"]["hit_rate_modal"] = round(float(D.club.value_counts(normalize=True).max()), 3)
# robustness: add initial carbon intensity
X2 = D[["log_gdppc_2000", "coal_2000", "hydro_2000", "nuclear_2000", "log_ci_2000"]]
om2 = OrderedModel(D.club, X2, distr="logit").fit(method="bfgs", disp=False, maxiter=2000)
R["ologit2"] = {"coef": {k: round(float(om2.params[k]), 4) for k in X2.columns}, "se": {k: round(float(om2.bse[k]), 4) for k in X2.columns}, "p": {k: float(om2.pvalues[k]) for k in X2.columns}, "llf": round(float(om2.llf), 2), "mcfadden_r2": round(float(1 - om2.llf / llf0), 3)}
R["club_profiles"] = D.groupby("club")[["log_gdppc_2000", "coal_2000", "hydro_2000", "nuclear_2000"]].mean().round(2).to_dict("index")
D.to_csv("out/determinants.csv", index=False)

# ---------------- implication: CO2 saving of a heat pump replacing a gas boiler, by club ----------------
EF_GAS = 56.1 * 3.6           # g CO2 per kWh of natural gas (IPCC 2006 default 56.1 t CO2/TJ)
BOILER = EF_GAS / 0.90        # g CO2 per kWh of heat from a 90%-efficient gas boiler
R["boiler_g_per_kwh_heat"] = round(BOILER, 1)
def hp_saving(ci, cop=3.0): return (1 - (ci / cop) / BOILER) * 100
R["hp_saving_by_club"] = {cl["club"]: round(float(hp_saving(CI[cl["members"]].iloc[-1]).median()), 1) for cl in R["clubs"]}
R["hp_saving_sens"] = {cop: {cl["club"]: round(float(hp_saving(CI[cl["members"]].iloc[-1], cop).median()), 1) for cl in R["clubs"]} for cop in (2.5, 3.5)}
R["hp_share_increase"] = {cl["club"]: round(float((hp_saving(CI[cl["members"]].iloc[-1]) < 0).mean() * 100), 1) for cl in R["clubs"]}
R["hp_breakeven_ci"] = {cop: round(BOILER * cop, 1) for cop in (2.5, 3.0, 3.5)}
R["tur"] = {"ci_2000": round(float(CI["TUR"].iloc[0]), 1), "ci_2024": round(float(CI["TUR"].iloc[-1]), 1)} if "TUR" in CI else None
json.dump(R, open("out/results.json", "w"), indent=1, default=str)
pd.Series(memb).to_csv("out/membership.csv")

# ================= FIGURES =================
cols = plt.cm.viridis(np.linspace(0.05, 0.9, len(initial)))
fig, ax = plt.subplots(figsize=(6.3, 4.2))
for k, cl in enumerate(initial):
    ax.scatter(CI[cl].iloc[0], CI[cl].iloc[-1], s=14, color=cols[k], label=f"Club {k + 1} (n = {len(cl)})", alpha=0.8, edgecolor="none")
if divergent: ax.scatter(CI[divergent].iloc[0], CI[divergent].iloc[-1], s=18, marker="x", color="grey", label=f"Divergent (n = {len(divergent)})")
lim = [15, 1500]; ax.plot(lim, lim, color="k", lw=0.7, ls="--"); ax.set_xscale("log"); ax.set_yscale("log"); ax.set_xlim(lim); ax.set_ylim(lim)
OFF = {"IND": (-18, 4), "ZAF": (4, 2), "CHN": (4, -6), "TUR": (-20, -9), "USA": (4, -4), "DEU": (-22, -9), "COG": (4, -2), "ZMB": (4, -2), "LAO": (4, -2)}
for iso in ["TUR", "DEU", "CHN", "IND", "FRA", "GBR", "POL", "ZAF", "USA", "GRC", "COG", "ZMB", "LAO"]:
    if iso in CI: ax.annotate(iso, (CI[iso].iloc[0], CI[iso].iloc[-1]), fontsize=6.5, xytext=OFF.get(iso, (3, -3)), textcoords="offset points")
ax.set_xlabel("Carbon intensity 2000 (gCO$_2$/kWh, log scale)"); ax.set_ylabel("Carbon intensity 2024 (gCO$_2$/kWh, log scale)"); ax.legend(frameon=False, fontsize=7)
fig.tight_layout(); fig.savefig("fig/fig1_scatter.png"); plt.show()
fig, ax = plt.subplots(1, 2, figsize=(9, 3.4))
gg = G.values; hh = pd.DataFrame(gg / gg.mean(axis=1, keepdims=True), index=G.index, columns=G.columns)
for k, cl in enumerate(initial):
    ax[0].plot(hh.index, hh[cl].mean(axis=1), color=cols[k], lw=1.5, label=f"Club {k + 1}")
    m = CI[cl]; ax[1].plot(m.index, m.median(axis=1), color=cols[k], lw=1.5)
    ax[1].fill_between(m.index, m.quantile(0.25, axis=1), m.quantile(0.75, axis=1), color=cols[k], alpha=0.15, lw=0)
if "TUR" in CI: ax[0].plot(hh.index, hh["TUR"], color="#d62728", ls="--", lw=1.2, label="Türkiye"); ax[1].plot(CI.index, CI["TUR"], color="#d62728", ls="--", lw=1.2)
ax[0].axhline(1, color="k", lw=0.6); ax[0].set_title("(a) Relative transition paths h$_{it}$ (club averages)"); ax[0].legend(frameon=False, fontsize=7)
ax[1].set_title("(b) Carbon intensity: club median and IQR"); ax[1].set_ylabel("gCO$_2$/kWh")
fig.tight_layout(); fig.savefig("fig/fig2_paths.png"); plt.show()
fig, ax = plt.subplots(figsize=(6.3, 3.4))
kk = list(R["ologit"]["coef"]); sc = [1 if k.startswith("log") else 10 for k in kk]
est = [R["ologit"]["coef"][k] * s for k, s in zip(kk, sc)]; se = [R["ologit"]["se"][k] * s for k, s in zip(kk, sc)]
ax.errorbar(est, range(len(kk)), xerr=[1.96 * s for s in se], fmt="o", color="k", capsize=3); ax.axvline(0, color="grey", lw=0.8)
ax.set_yticks(range(len(kk))); ax.set_yticklabels(["log GDP per capita, 2000–02", "Coal share, per 10 pp", "Hydro share, per 10 pp", "Nuclear share, per 10 pp"])
ax.set_xlabel("Ordered-logit coefficient (higher = higher-intensity club), 95% CI"); fig.tight_layout(); fig.savefig("fig/fig3_ologit.png"); plt.show()
fig, ax = plt.subplots(figsize=(6.3, 3.4))
data = [hp_saving(CI[cl].iloc[-1]) for cl in initial]
ax.boxplot(data, tick_labels=[f"Club {k + 1}" for k in range(len(initial))], patch_artist=True, boxprops=dict(facecolor="#c6dbef"))
ax.axhline(0, color="k", lw=0.7); ax.set_ylabel("CO$_2$ saving of a heat pump (COP 3)\nvs. a gas boiler (%)")
if "TUR" in CI: ax.axhline(hp_saving(CI["TUR"].iloc[-1]), color="#d62728", ls="--", lw=1, label="Türkiye"); ax.legend(frameon=False)
fig.tight_layout(); fig.savefig("fig/fig4_heatpump.png"); plt.show()
print(json.dumps({k: R[k] for k in ["N", "T", "full_panel", "turkiye_club", "adjacent_tests", "pre_merge_adjacent", "ps_merge", "robustness", "ologit", "ologit2", "hp_saving_by_club", "hp_saving_sens", "hp_share_increase", "hp_breakeven_ci", "tur"]}, indent=1, default=str))
for cl in R["clubs"]: print(cl["club"], cl["n"], cl["b"], cl["t"], cl["mean_ci_2000"], cl["mean_ci_2024"], cl["pct_change"])
print("divergent", divergent)
for c in R["pre_merge"]: print("pre", c["n"], c["t"], c["b"], c["mean_ci_2024"])

# ---------------- descriptive: change in generation mix by club (2000 -> 2024) ----------------
low = panel("lowcarbon")
def d(P, c):
    try: return float(P.loc[2024, c] - P.loc[2000, c])
    except Exception: return np.nan
chg = pd.DataFrame([(u, memb[u], d(coal, u), d(low, u), d(hyd, u), d(nuc, u), v(low, u)) for u in CI.columns if memb.get(u, 0) > 0],
                   columns=["iso", "club", "d_coal", "d_lowcarbon", "d_hydro", "d_nuclear", "lowcarbon_2000"])
chg["d_other_lowcarbon"] = chg.d_lowcarbon - chg.d_hydro - chg.d_nuclear.fillna(0)
R["mix_change"] = chg.groupby("club")[["d_coal", "d_lowcarbon", "d_hydro", "d_nuclear", "d_other_lowcarbon", "lowcarbon_2000"]].mean().round(1).to_dict("index")
R["mix_change_n"] = chg.groupby("club")[["d_coal", "d_lowcarbon", "d_hydro", "d_nuclear"]].count().to_dict("index")
R["lowcarbon_by_club"] = {int(k): {"lc_2000": round(float(low.loc[2000, g.iso].mean()), 1), "lc_2024": round(float(low.loc[2024, g.iso].mean()), 1)} for k, g in chg.groupby("club")}
# Spearman: within-club-3 reduction vs change in low-carbon share
c3 = chg[chg.club == 3].copy(); c3["d_log_ci"] = [np.log(CI[u].iloc[-1] / CI[u].iloc[0]) for u in c3.iso]
from scipy.stats import spearmanr
rho, p = spearmanr(c3.d_lowcarbon, c3.d_log_ci, nan_policy="omit")
R["club3_spearman_dlow_dlogci"] = {"rho": round(float(rho), 3), "p": float(p), "n": int(c3.d_lowcarbon.notna().sum())}
R["focus"] = {u: {"club": memb[u], "ci_2000": round(float(CI[u].iloc[0]), 1), "ci_2024": round(float(CI[u].iloc[-1]), 1)} for u in ["TUR", "DEU", "GBR", "DNK", "CHN", "IND", "USA", "POL", "FRA", "BRA", "ESP", "GRC", "ITA", "JPN", "KOR"] if u in memb}
json.dump(R, open("out/results.json", "w"), indent=1, default=str)
print(R["mix_change"], R["mix_change_n"], R["lowcarbon_by_club"], R["club3_spearman_dlow_dlogci"]); print(R["focus"])

# ## Sonuçlar ve çıktılar

# Packs figures and numerical results for download.
import shutil
from google.colab import files
shutil.make_archive("/content/rp03_outputs", "zip", ".", ".")
files.download("/content/rp03_outputs.zip")
