{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Different types of typical usage of the package\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## General usage\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Importing the library\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "from geopolrisk.assessment.main import (\n",
    "    gprs_calc,\n",
    ")  # This is a one stop function to calculate all the values of the GeoPolRisk method"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Prepare the lists\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "from geopolrisk.assessment.utils import (\n",
    "    default_rmlist,\n",
    ")  # This is a functions that returns the default list of metals that are available in the library database\n",
    "\n",
    "ListofMetals = default_rmlist()\n",
    "ListofAlternateMetals = [\n",
    "    \"Aluminium\",\n",
    "    \"Copper\",\n",
    "    \"Nickel\",\n",
    "    \"Tin\",\n",
    "    \"Zinc\",\n",
    "]  # If you want to use a different list of metals, you can specify them here (of course, they must be available in the library database)\n",
    "# Aluminium is an exception in the database, it refers to primary metal not raw material. The raw material is bauxite\n",
    "\n",
    "ListofCountries = [\n",
    "    \"China\",\n",
    "    \"Germany\",\n",
    "    842,\n",
    "    36,\n",
    "]  # List of countries to be assessed, you can use the ISO 3166-1 numeric code & \"EU\" for European Union\n",
    "\n",
    "ListofYear = [\n",
    "    2022\n",
    "]  # List of years to be assessed, you can only use the year as an integer"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### GeoPolRisk Calculation using main function\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Calculating the GeoPolRisk: 100%|██████████| 212/212 [00:08<00:00, 25.61it/s]\n"
     ]
    },
    {
     "data": {
      "application/vnd.microsoft.datawrangler.viewer.v0+json": {
       "columns": [
        {
         "name": "index",
         "rawType": "int64",
         "type": "integer"
        },
        {
         "name": "DBID",
         "rawType": "object",
         "type": "string"
        },
        {
         "name": "Country [Economic Entity]",
         "rawType": "object",
         "type": "string"
        },
        {
         "name": "Raw Material",
         "rawType": "object",
         "type": "string"
        },
        {
         "name": "Year",
         "rawType": "int64",
         "type": "integer"
        },
        {
         "name": "GeoPolRisk Score",
         "rawType": "float64",
         "type": "float"
        },
        {
         "name": "GeoPolRisk Characterization Factor [eq. Kg-Cu/Kg]",
         "rawType": "float64",
         "type": "float"
        },
        {
         "name": "HHI",
         "rawType": "float64",
         "type": "float"
        },
        {
         "name": "Import Risk",
         "rawType": "float64",
         "type": "float"
        },
        {
         "name": "Price",
         "rawType": "float64",
         "type": "float"
        }
       ],
       "ref": "79ee19cc-74ca-48a3-9522-8a7a6a9ad884",
       "rows": [
        [
         "0",
         "Aluminium1562022",
         "China",
         "Aluminium",
         "2022",
         "0.003944874781380299",
         "0.024356630597795206",
         "0.3532792047080751",
         "0.01116645058301709",
         "2.5278165947009335"
        ],
        [
         "1",
         "Antimony1562022",
         "China",
         "Antimony",
         "2022",
         "0.07612793030702521",
         "0.7224165698472998",
         "0.276644236014858",
         "0.27518350428575905",
         "3.885127263441932"
        ],
        [
         "2",
         "Arsenic1562022",
         "China",
         "Arsenic",
         "2022",
         "0.00015216057049886314",
         "0.07535318712565135",
         "0.3932371143058169",
         "0.0003869435639804061",
         "202.75009735547138"
        ],
        [
         "3",
         "Asbestos1562022",
         "China",
         "Asbestos",
         "2022",
         "0.10858757648585425",
         "0.08165503151025084",
         "0.3349175309162646",
         "0.32422183511499464",
         "0.30786788186583863"
        ],
        [
         "4",
         "Baryte1562022",
         "China",
         "Baryte",
         "2022",
         "0.00198077569788993",
         "0.0005360552511472624",
         "0.1513743257945944",
         "0.013085281717969268",
         "0.11079899702771734"
        ],
        [
         "5",
         "Bauxite1562022",
         "China",
         "Bauxite",
         "2022",
         "0.06445723991862984",
         "0.008673293782450617",
         "0.18342379925561927",
         "0.3514115408153894",
         "0.055090146286528426"
        ],
        [
         "6",
         "Bentonite1562022",
         "China",
         "Bentonite",
         "2022",
         "0.0059247540216603185",
         "0.0026010994629484165",
         "0.1313612728768959",
         "0.0451027452148142",
         "0.17974143656828134"
        ],
        [
         "7",
         "Beryllium1562022",
         "China",
         "Beryllium",
         "2022",
         "0.06654457957773253",
         "5.470628901543",
         "0.4852018684461631",
         "0.13714823438507878",
         "33.65783239156861"
        ],
        [
         "8",
         "Bismuth1562022",
         "China",
         "Bismuth",
         "2022",
         "0.0329879075133884",
         "0.8241822435476476",
         "0.5711330304233744",
         "0.057758710766447605",
         "10.228926520518085"
        ],
        [
         "9",
         "Boron1562022",
         "China",
         "Boron",
         "2022",
         "0.11774602172308436",
         "0.0976254778505749",
         "0.29847521717046893",
         "0.39449178675305485",
         "0.33945210293993766"
        ],
        [
         "10",
         "Cadmium1562022",
         "China",
         "Cadmium",
         "2022",
         "0.026428358103837278",
         "0.17856669049440702",
         "0.19454830922947364",
         "0.13584470720156452",
         "2.7662526322172045"
        ],
        [
         "11",
         "Chromite1562022",
         "China",
         "Chromite",
         "2022",
         "0.19862359681683367",
         "0.15926881019029498",
         "0.3070140864060876",
         "0.6469527152383301",
         "0.3282928823637874"
        ],
        [
         "12",
         "Cobalt1562022",
         "China",
         "Cobalt",
         "2022",
         "0.4325693932200459",
         "17.164243776457226",
         "0.4928971158048766",
         "0.8776058519102541",
         "16.24540190511184"
        ],
        [
         "13",
         "Coking Coal1562022",
         "China",
         "Coking Coal",
         "2022",
         "0.03040504829579388",
         "0.014893300555122896",
         "0.3272799988428909",
         "0.09290225007116817",
         "0.20054268706971295"
        ],
        [
         "14",
         "Copper1562022",
         "China",
         "Copper",
         "2022",
         "0.050723813898777524",
         "0.33164430911470666",
         "0.10368441992479659",
         "0.4892134607645782",
         "2.676838822747666"
        ],
        [
         "15",
         "Diatomite1562022",
         "China",
         "Diatomite",
         "2022",
         "0.003795208311966407",
         "0.008361129390965734",
         "0.15162522238314766",
         "0.0250301912328026",
         "0.9019675209319644"
        ],
        [
         "16",
         "Feldspar1562022",
         "China",
         "Feldspar",
         "2022",
         "0.00349648697668383",
         "0.00250011544943821",
         "0.20066377210066477",
         "0.01742460504993291",
         "0.29274515916133487"
        ],
        [
         "17",
         "Fluorspar1562022",
         "China",
         "Fluorspar",
         "2022",
         "0.002042730941896549",
         "0.0016768084976808634",
         "0.42615798826202134",
         "0.0047933653672134965",
         "0.33607319309002787"
        ],
        [
         "18",
         "Germanium1562022",
         "China",
         "Germanium",
         "2022",
         "0.0",
         "0.0",
         "0.8764039128409503",
         "0.0",
         "0.0"
        ],
        [
         "19",
         "Gold1562022",
         "China",
         "Gold",
         "2022",
         "0.027371959548577587",
         "3.5316707378560706",
         "0.049356777146401465",
         "0.5545734776682687",
         "52.8245603163668"
        ],
        [
         "20",
         "Graphite1562022",
         "China",
         "Graphite",
         "2022",
         "0.04241530201200386",
         "0.06460173046648177",
         "0.470663478647389",
         "0.09011810759971987",
         "0.623567053906595"
        ],
        [
         "21",
         "Gypsum1562022",
         "China",
         "Gypsum",
         "2022",
         "0.0009742649285415945",
         "0.00012489216301906326",
         "0.07039292364592355",
         "0.013840381647481326",
         "0.05248312563223737"
        ],
        [
         "22",
         "Iron1562022",
         "China",
         "Iron",
         "2022",
         "0.06841081992740715",
         "0.016974573187842387",
         "0.20252183624846373",
         "0.33779478398308316",
         "0.10158641655297738"
        ],
        [
         "23",
         "Kaolin1562022",
         "China",
         "Kaolin",
         "2022",
         "0.003884208106424958",
         "0.002608905305348987",
         "0.10187742563033231",
         "0.03812628835478249",
         "0.27499031536157076"
        ],
        [
         "24",
         "Lead1562022",
         "China",
         "Lead",
         "2022",
         "0.055377802067640716",
         "0.2101432230798394",
         "0.2016226144381781",
         "0.2746606685066112",
         "1.5536072803729477"
        ],
        [
         "25",
         "Lignite1562022",
         "China",
         "Lignite",
         "2022",
         "0.05220313501374145",
         "0.01186973606060962",
         "0.08802223420123098",
         "0.5930675980616201",
         "0.09309064735818817"
        ],
        [
         "26",
         "Lithium1562022",
         "China",
         "Lithium",
         "2022",
         "0.10939778663755512",
         "12.002550967511196",
         "0.31981095428556255",
         "0.3420701673022516",
         "44.91863982047043"
        ],
        [
         "27",
         "Magnesite1562022",
         "China",
         "Magnesite",
         "2022",
         "0.0001509219990525094",
         "7.215560129402191e-05",
         "0.42040077556916244",
         "0.0003589955295591038",
         "0.1957397703844351"
        ],
        [
         "28",
         "Manganese1562022",
         "China",
         "Manganese",
         "2022",
         "0.10928837215731124",
         "0.04422355880122361",
         "0.2035183372902862",
         "0.5369952094362335",
         "0.16566902061455088"
        ],
        [
         "29",
         "Mercury1562022",
         "China",
         "Mercury",
         "2022",
         "0.030905871879422002",
         "0.06278486377043065",
         "0.49775437404450484",
         "0.0620906083221253",
         "0.8317169069462647"
        ],
        [
         "30",
         "Molybdenum1562022",
         "China",
         "Molybdenum",
         "2022",
         "0.025076005909895355",
         "0.8228283068608605",
         "0.2326102658434335",
         "0.10780266218677399",
         "13.434219309894848"
        ],
        [
         "31",
         "Natural gas1562022",
         "China",
         "Natural gas",
         "2022",
         "0.04602111250428812",
         "0.10100197924798625",
         "0.1038190611969056",
         "0.4432819173446717",
         "0.8985336474406143"
        ],
        [
         "32",
         "Nickel1562022",
         "China",
         "Nickel",
         "2022",
         "0.1672974995645474",
         "0.03156457019904723",
         "0.26749007657640966",
         "0.625434415010002",
         "0.07724528920743906"
        ],
        [
         "33",
         "Niobium1562022",
         "China",
         "Niobium",
         "2022",
         "0.47792720631772756",
         "28.95651418754137",
         "0.8692862183478102",
         "0.5497926876444555",
         "24.805392286966356"
        ],
        [
         "34",
         "Palladium1562022",
         "China",
         "Palladium",
         "2022",
         "0.1680769600583267",
         "31723.15067881988",
         "0.3236120898438461",
         "0.5193778765788064",
         "77273.34332294414"
        ],
        [
         "35",
         "Crude oil1562022",
         "China",
         "Crude oil",
         "2022",
         "0.03498905836878478",
         "0.06011832256489711",
         "0.08372461716439887",
         "0.4179064599373614",
         "0.7034547603621121"
        ],
        [
         "36",
         "Phosphate1562022",
         "China",
         "Phosphate",
         "2022",
         "8.45787953378266e-07",
         "2.3552931668967124e-06",
         "0.2348754375481461",
         "3.6010063981462157e-06",
         "1.1401055252819092"
        ],
        [
         "37",
         "Platinum1562022",
         "China",
         "Platinum",
         "2022",
         "0.15788184470138938",
         "195.78659743314861",
         "0.5620044925741473",
         "0.2809263035927768",
         "507.70605186176425"
        ],
        [
         "38",
         "Rare earth1562022",
         "China",
         "Rare earth",
         "2022",
         "0.06735521129532937",
         "5.688704005879153",
         "0.5282617688739127",
         "0.12750347510271168",
         "34.578305561753844"
        ],
        [
         "39",
         "Rhodium1562022",
         "China",
         "Rhodium",
         "2022",
         "0.3496015252083816",
         "358153.3175070907",
         "0.699713407838737",
         "0.49963530967374903",
         "419427.8199134199"
        ],
        [
         "40",
         "Selenium1562022",
         "China",
         "Selenium",
         "2022",
         "0.04461733866513335",
         "1.9653465901977893",
         "0.1970920899125283",
         "0.22637812955829445",
         "18.03420744956752"
        ],
        [
         "41",
         "Silver1562022",
         "China",
         "Silver",
         "2022",
         "0.064071120205813",
         "0.3457651924900294",
         "0.11857763803203183",
         "0.5403305485685692",
         "2.2094314305478147"
        ],
        [
         "42",
         "Steam Coal1562022",
         "China",
         "Steam Coal",
         "2022",
         "0.010183207196434264",
         "0.00420003401813395",
         "0.3770712498410497",
         "0.027006055753990486",
         "0.16886117270270415"
        ],
        [
         "43",
         "Sulfur1562022",
         "China",
         "Sulfur",
         "2022",
         "0.012627354310119503",
         "0.009276296186308446",
         "0.08458930789358836",
         "0.14927837364510016",
         "0.30076258849521076"
        ],
        [
         "44",
         "Tantalum1562022",
         "China",
         "Tantalum",
         "2022",
         "0.023579665273257465",
         "13.840821576505155",
         "0.18845843476299362",
         "0.12511865177545056",
         "240.31772710555347"
        ],
        [
         "45",
         "Tellurium1562022",
         "China",
         "Tellurium",
         "2022",
         "0.12763744351211437",
         "12.062035947150504",
         "0.5563361300324952",
         "0.2294250483150522",
         "38.69047796727572"
        ],
        [
         "46",
         "Tin1562022",
         "China",
         "Tin",
         "2022",
         "0.040842941828769457",
         "0.7360496127889187",
         "0.13707362475950757",
         "0.2979635352930035",
         "7.3782207733602165"
        ],
        [
         "47",
         "Titanium1562022",
         "China",
         "Titanium",
         "2022",
         "0.0396140972483474",
         "0.03495718031214001",
         "0.17493243990142024",
         "0.2264536941842871",
         "0.3612835641725462"
        ],
        [
         "48",
         "Tungsten1562022",
         "China",
         "Tungsten",
         "2022",
         "0.030556001597512476",
         "0.8089467775753436",
         "0.6007017512773754",
         "0.05086717581984071",
         "10.83889473972222"
        ],
        [
         "49",
         "Uranium1562022",
         "China",
         "Uranium",
         "2022",
         "0.00019148748053350706",
         "0.00937327716943712",
         "0.24703176337277888",
         "0.0007751532755103492",
         "20.040688966550174"
        ]
       ],
       "shape": {
        "columns": 9,
        "rows": 212
       }
      },
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>DBID</th>\n",
       "      <th>Country [Economic Entity]</th>\n",
       "      <th>Raw Material</th>\n",
       "      <th>Year</th>\n",
       "      <th>GeoPolRisk Score</th>\n",
       "      <th>GeoPolRisk Characterization Factor [eq. Kg-Cu/Kg]</th>\n",
       "      <th>HHI</th>\n",
       "      <th>Import Risk</th>\n",
       "      <th>Price</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Aluminium1562022</td>\n",
       "      <td>China</td>\n",
       "      <td>Aluminium</td>\n",
       "      <td>2022</td>\n",
       "      <td>0.003945</td>\n",
       "      <td>0.024357</td>\n",
       "      <td>0.353279</td>\n",
       "      <td>0.011166</td>\n",
       "      <td>2.527817</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Antimony1562022</td>\n",
       "      <td>China</td>\n",
       "      <td>Antimony</td>\n",
       "      <td>2022</td>\n",
       "      <td>0.076128</td>\n",
       "      <td>0.722417</td>\n",
       "      <td>0.276644</td>\n",
       "      <td>0.275184</td>\n",
       "      <td>3.885127</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Arsenic1562022</td>\n",
       "      <td>China</td>\n",
       "      <td>Arsenic</td>\n",
       "      <td>2022</td>\n",
       "      <td>0.000152</td>\n",
       "      <td>0.075353</td>\n",
       "      <td>0.393237</td>\n",
       "      <td>0.000387</td>\n",
       "      <td>202.750097</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Asbestos1562022</td>\n",
       "      <td>China</td>\n",
       "      <td>Asbestos</td>\n",
       "      <td>2022</td>\n",
       "      <td>0.108588</td>\n",
       "      <td>0.081655</td>\n",
       "      <td>0.334918</td>\n",
       "      <td>0.324222</td>\n",
       "      <td>0.307868</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Baryte1562022</td>\n",
       "      <td>China</td>\n",
       "      <td>Baryte</td>\n",
       "      <td>2022</td>\n",
       "      <td>0.001981</td>\n",
       "      <td>0.000536</td>\n",
       "      <td>0.151374</td>\n",
       "      <td>0.013085</td>\n",
       "      <td>0.110799</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",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>207</th>\n",
       "      <td>Tungsten362022</td>\n",
       "      <td>Australia</td>\n",
       "      <td>Tungsten</td>\n",
       "      <td>2022</td>\n",
       "      <td>0.050577</td>\n",
       "      <td>4.720357</td>\n",
       "      <td>0.600702</td>\n",
       "      <td>0.084197</td>\n",
       "      <td>38.210378</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>208</th>\n",
       "      <td>Uranium362022</td>\n",
       "      <td>Australia</td>\n",
       "      <td>Uranium</td>\n",
       "      <td>2022</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.247032</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>209</th>\n",
       "      <td>Vanadium362022</td>\n",
       "      <td>Australia</td>\n",
       "      <td>Vanadium</td>\n",
       "      <td>2022</td>\n",
       "      <td>0.259805</td>\n",
       "      <td>6.958138</td>\n",
       "      <td>0.502120</td>\n",
       "      <td>0.517417</td>\n",
       "      <td>10.964943</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>210</th>\n",
       "      <td>Zinc362022</td>\n",
       "      <td>Australia</td>\n",
       "      <td>Zinc</td>\n",
       "      <td>2022</td>\n",
       "      <td>0.008650</td>\n",
       "      <td>0.043827</td>\n",
       "      <td>0.138882</td>\n",
       "      <td>0.062280</td>\n",
       "      <td>2.074484</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>211</th>\n",
       "      <td>Zirconium362022</td>\n",
       "      <td>Australia</td>\n",
       "      <td>Zirconium</td>\n",
       "      <td>2022</td>\n",
       "      <td>0.000821</td>\n",
       "      <td>0.004560</td>\n",
       "      <td>0.194716</td>\n",
       "      <td>0.004217</td>\n",
       "      <td>2.273523</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>212 rows × 9 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                 DBID Country [Economic Entity] Raw Material  Year  \\\n",
       "0    Aluminium1562022                     China    Aluminium  2022   \n",
       "1     Antimony1562022                     China     Antimony  2022   \n",
       "2      Arsenic1562022                     China      Arsenic  2022   \n",
       "3     Asbestos1562022                     China     Asbestos  2022   \n",
       "4       Baryte1562022                     China       Baryte  2022   \n",
       "..                ...                       ...          ...   ...   \n",
       "207    Tungsten362022                 Australia     Tungsten  2022   \n",
       "208     Uranium362022                 Australia      Uranium  2022   \n",
       "209    Vanadium362022                 Australia     Vanadium  2022   \n",
       "210        Zinc362022                 Australia         Zinc  2022   \n",
       "211   Zirconium362022                 Australia    Zirconium  2022   \n",
       "\n",
       "     GeoPolRisk Score  GeoPolRisk Characterization Factor [eq. Kg-Cu/Kg]  \\\n",
       "0            0.003945                                           0.024357   \n",
       "1            0.076128                                           0.722417   \n",
       "2            0.000152                                           0.075353   \n",
       "3            0.108588                                           0.081655   \n",
       "4            0.001981                                           0.000536   \n",
       "..                ...                                                ...   \n",
       "207          0.050577                                           4.720357   \n",
       "208          0.000000                                           0.000000   \n",
       "209          0.259805                                           6.958138   \n",
       "210          0.008650                                           0.043827   \n",
       "211          0.000821                                           0.004560   \n",
       "\n",
       "          HHI  Import Risk       Price  \n",
       "0    0.353279     0.011166    2.527817  \n",
       "1    0.276644     0.275184    3.885127  \n",
       "2    0.393237     0.000387  202.750097  \n",
       "3    0.334918     0.324222    0.307868  \n",
       "4    0.151374     0.013085    0.110799  \n",
       "..        ...          ...         ...  \n",
       "207  0.600702     0.084197   38.210378  \n",
       "208  0.247032     0.000000    0.000000  \n",
       "209  0.502120     0.517417   10.964943  \n",
       "210  0.138882     0.062280    2.074484  \n",
       "211  0.194716     0.004217    2.273523  \n",
       "\n",
       "[212 rows x 9 columns]"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "gprs_calc(\n",
    "    ListofYear, ListofCountries, ListofMetals\n",
    ")  # This is the main function that calculates the GeoPolRisk values for the specified list of countries, years and metals\n",
    "# The function returns a pandas DataFrame with the results, which is also saved as an excel file in a folder named \"ouput\" in the document folder of the users home directory"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Using individual functions from the core module\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Extract random values from the list above\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "import random\n",
    "\n",
    "RandomMetal = random.choice(ListofMetals)\n",
    "RandomCountry = random.choice(ListofCountries)\n",
    "RandomYear = random.choice(ListofYear)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Calculate the HHI & extract the production quantity of a raw material in a country at a particular time period\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from geopolrisk.assessment.core import (\n",
    "    HHI,\n",
    ")  # This is the Herfindahl-Hirschman Index function to calculate the concentration of production in a country for a specific metal and year\n",
    "\n",
    "ProductionQuantity, hhi = HHI(RandomMetal, RandomYear, RandomCountry)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Calculate the import risk component of the GeoPolRisk method\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "from geopolrisk.assessment.core import (\n",
    "    importrisk,\n",
    ")  # This is the function to import risk values for a specific metal, year and country from the mapped baci data\n",
    "\n",
    "\n",
    "from geopolrisk.assessment.utils import (\n",
    "    mapped_baci,\n",
    ")  # This is a function to get the mapped baci data, which is a pandas DataFrame with the trade data for the specified countries, years and metals\n",
    "\n",
    "mapped_baci = (\n",
    "    mapped_baci()\n",
    ")  # This is a function that returns the mapped baci data, which is a pandas DataFrame with the trade data for the specified countries, years and metals\n",
    "\n",
    "\n",
    "Numerator, TotalTrade, Price = importrisk(\n",
    "    RandomMetal, RandomYear, RandomCountry, data=mapped_baci\n",
    ")  # The functions returns the values required to calculate the import risk for the specified metal, year and country\n",
    "# The values are the numerator of the import risk formula (i.e. the import share wieghted by the political stability of the exporting countries), the total trade value and the price of the metal in USD per kilogram"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Calculate the Values of the GeoPolrisk Method\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "from geopolrisk.assessment.core import (\n",
    "    GeoPolRisk,\n",
    ")  # This is the main function to calculate the GeoPolRisk values based on the numerator, total trade, price, production quantity and Herfindahl-Hirschman Index\n",
    "\n",
    "\n",
    "Values = GeoPolRisk(\n",
    "    Numerator, TotalTrade, Price, ProductionQuantity, hhi\n",
    ")  # This function returns a dictionary with the GeoPolRisk values for the specified metal, year and country\n",
    "# The values are the GeoPolRisk Score, the characterization factor, the import risk"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'\\nThe three values correspond to \"the GeoPolRisk Score\", \"the characterization factor (GSP)\", \"the import risk component\"\\n'"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Values\n",
    "\"\"\"\n",
    "The three values correspond to \"the GeoPolRisk Score\", \"the characterization factor (GSP)\", \"the import risk component\"\n",
    "\"\"\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Company level assessment\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Company data in the template file located in the \"database\" folder in the users document directory\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "  rawMaterial  partnerDesc    qty  cifvalue  period  Notes  partnerISO  \\\n",
      "0      Nickel      Denmark  170.0    3196.0    2022    NaN         208   \n",
      "1      Nickel  Netherlands    1.0      73.0    2022    NaN         528   \n",
      "2      Nickel     Portugal  893.0    2782.0    2022    NaN         620   \n",
      "3      Nickel        Egypt    4.0     113.0    2022    NaN         818   \n",
      "4      Nickel          USA  498.0    3355.0    2022    NaN         842   \n",
      "\n",
      "   partnerWGI cmdCode reporterDesc  reporterISO  \n",
      "0    0.326998  Nickel      Company          999  \n",
      "1    0.356539  Nickel      Company          999  \n",
      "2    0.327856  Nickel      Company          999  \n",
      "3    0.705611  Nickel      Company          999  \n",
      "4    0.507201  Nickel      Company          999  \n"
     ]
    }
   ],
   "source": [
    "from geopolrisk.assessment.core import importrisk_company\n",
    "\n",
    "\"\"\"\n",
    "Modify the template file located in the the 'geopolrisk/database' location of the document directory.\n",
    "This function calculates the import risk values for a specific metal, year and country based on the company data in the database folder.\n",
    "\"\"\"\n",
    "\n",
    "\n",
    "Numerator_C, TotalTrade_C, Price_C = importrisk_company(\"Nickel\", 2022)\n",
    "\n",
    "Values_c = GeoPolRisk(Numerator_C, TotalTrade_C, Price_C, ProductionQuantity, hhi)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Company data using different parameters\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "  rawMaterial  partnerDesc    qty  cifvalue  period  Notes  partnerISO  \\\n",
      "0      Nickel      Denmark  170.0    3196.0    2022    NaN         208   \n",
      "1      Nickel  Netherlands    1.0      73.0    2022    NaN         528   \n",
      "2      Nickel     Portugal  893.0    2782.0    2022    NaN         620   \n",
      "3      Nickel        Egypt    4.0     113.0    2022    NaN         818   \n",
      "4      Nickel          USA  498.0    3355.0    2022    NaN         842   \n",
      "\n",
      "   partnerWGI cmdCode reporterDesc  reporterISO  \n",
      "0    0.326998  Nickel      Company          999  \n",
      "1    0.356539  Nickel      Company          999  \n",
      "2    0.327856  Nickel      Company          999  \n",
      "3    0.705611  Nickel      Company          999  \n",
      "4    0.507201  Nickel      Company          999  \n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "<>:3: SyntaxWarning: invalid escape sequence '\\R'\n",
      "<>:3: SyntaxWarning: invalid escape sequence '\\R'\n",
      "C:\\Users\\anish\\AppData\\Local\\Temp\\ipykernel_32080\\2755402762.py:3: SyntaxWarning: invalid escape sequence '\\R'\n",
      "  ExcelFile = \"C:\\Random Folder\\Company data.xlsx\"  # Specify the path to the Company data.xlsx file\n"
     ]
    }
   ],
   "source": [
    "from geopolrisk.assessment.core import HHI, importrisk_company, GeoPolRisk\n",
    "\n",
    "ExcelFile = \"C:\\Random Folder\\Company data.xlsx\"  # Specify the path to the Company data.xlsx file\n",
    "SheetName = \"Template\"  # Specify the sheet name in the Excel file\n",
    "RawMaterial = (\n",
    "    \"Nickel\"  # Specify the raw material for which you want to import risk values\n",
    ")\n",
    "Year = 2022  # Specify the year for which you want to import risk values\n",
    "\n",
    "from geopolrisk.assessment.core import (\n",
    "    HHI,\n",
    ")  # This is the HHI function to calculate the concentration of production in a country for a specific metal and year\n",
    "\n",
    "ProductionQuantity, hhi = HHI(RawMaterial, Year, \"Company\")\n",
    "\"\"\" The parameter \"Company\" is used to specify that the production quantity is for a company, not a country. \n",
    "In the HHI function, this will be used to get the production quantity for the specified raw material and year. \n",
    "The production Quantity should be 0 as a default value.\n",
    "If the company recycles the said raw material, user can manually provide it in \"metric tonnes\" as unit.\n",
    "\"\"\"\n",
    "Num_Company, TotalTrade_Company, Price_Company = importrisk_company(RawMaterial, 2022)\n",
    "Values_Company = GeoPolRisk(\n",
    "    Num_Company, TotalTrade_Company, Price_Company, ProductionQuantity, hhi\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Regional level assessment\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Define regions\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [],
   "source": [
    "# you can create regions or group of countries, the following is an example of how to create regions\n",
    "NewRegions = {\n",
    "    \"EFTA\": [\"Iceland\", \"Norway\", \"Switzerland\"],\n",
    "    \"NAFTA\": [\"Canada\", \"Mexico\", \"USA\"],\n",
    "}  # Liechtenstein has a customs union with Switzerland whose trade is not reported by UN Comtrade"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [],
   "source": [
    "from geopolrisk.assessment.utils import regions\n",
    "\n",
    "# This function updates the regions in the library (temporary variable only) and must be instantiated for the above new regions to be used\n",
    "regions(NewRegions)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Quickly check the regions\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Iceland', 'Norway', 'Switzerland']"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from geopolrisk.assessment.database import databases\n",
    "\n",
    "databases.regionslist[\"EFTA\"]\n",
    "# A quick check to see if the regions have been updated in the library"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Main Function to run for the regional assessment\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Calculating the GeoPolRisk: 100%|██████████| 106/106 [00:12<00:00,  8.79it/s]\n"
     ]
    },
    {
     "data": {
      "application/vnd.microsoft.datawrangler.viewer.v0+json": {
       "columns": [
        {
         "name": "index",
         "rawType": "int64",
         "type": "integer"
        },
        {
         "name": "DBID",
         "rawType": "object",
         "type": "string"
        },
        {
         "name": "Country [Economic Entity]",
         "rawType": "object",
         "type": "string"
        },
        {
         "name": "Raw Material",
         "rawType": "object",
         "type": "string"
        },
        {
         "name": "Year",
         "rawType": "int64",
         "type": "integer"
        },
        {
         "name": "GeoPolRisk Score",
         "rawType": "float64",
         "type": "float"
        },
        {
         "name": "GeoPolRisk Characterization Factor [eq. Kg-Cu/Kg]",
         "rawType": "float64",
         "type": "float"
        },
        {
         "name": "HHI",
         "rawType": "float64",
         "type": "float"
        },
        {
         "name": "Import Risk",
         "rawType": "float64",
         "type": "float"
        },
        {
         "name": "Price",
         "rawType": "float64",
         "type": "float"
        }
       ],
       "ref": "2ba4882d-2ce7-4e38-9526-082b6e99bfa3",
       "rows": [
        [
         "0",
         "AluminiumEFTA2022",
         "EFTA",
         "Aluminium",
         "2022",
         "0.028891620602832343",
         "0.2503054592971649",
         "0.3532792047080751",
         "0.08178126597263581",
         "3.54699022945428"
        ],
        [
         "1",
         "AntimonyEFTA2022",
         "EFTA",
         "Antimony",
         "2022",
         "0.11544242730733364",
         "0.011542208619514951",
         "0.276644236014858",
         "0.4172956175422844",
         "0.04093408088835664"
        ],
        [
         "2",
         "ArsenicEFTA2022",
         "EFTA",
         "Arsenic",
         "2022",
         "0.16417611804962",
         "4.912686171929291",
         "0.3932371143058169",
         "0.41749904085081285",
         "12.25097384529772"
        ],
        [
         "3",
         "AsbestosEFTA2022",
         "EFTA",
         "Asbestos",
         "2022",
         "0.18966162238401207",
         "0.23633082996732183",
         "0.3349175309162646",
         "0.5662935047476834",
         "0.5101554051051095"
        ],
        [
         "4",
         "BaryteEFTA2022",
         "EFTA",
         "Baryte",
         "2022",
         "0.07091087072878785",
         "0.034209486800308615",
         "0.1513743257945944",
         "0.46844714489436945",
         "0.19751283119973687"
        ],
        [
         "5",
         "BauxiteEFTA2022",
         "EFTA",
         "Bauxite",
         "2022",
         "0.07983444951239206",
         "0.01079964469462789",
         "0.18342379925561927",
         "0.4352458614224582",
         "0.05538353929645182"
        ],
        [
         "6",
         "BentoniteEFTA2022",
         "EFTA",
         "Bentonite",
         "2022",
         "0.05460665511706823",
         "0.05568855071868037",
         "0.1313612728768959",
         "0.41569827941787985",
         "0.4175244513824112"
        ],
        [
         "7",
         "BerylliumEFTA2022",
         "EFTA",
         "Beryllium",
         "2022",
         "0.19100199130804343",
         "20.19886974570149",
         "0.4852018684461631",
         "0.39365469040694057",
         "43.29629629629629"
        ],
        [
         "8",
         "BismuthEFTA2022",
         "EFTA",
         "Bismuth",
         "2022",
         "0.26922443180484457",
         "16.74559624479905",
         "0.5711330304233744",
         "0.47138655525713785",
         "25.465236860711762"
        ],
        [
         "9",
         "BoronEFTA2022",
         "EFTA",
         "Boron",
         "2022",
         "0.15130170133514975",
         "0.22222138735655853",
         "0.29847521717046893",
         "0.5069154577371039",
         "0.6013171861482723"
        ],
        [
         "10",
         "CadmiumEFTA2022",
         "EFTA",
         "Cadmium",
         "2022",
         "0.0007576799269069847",
         "0.014581276883216494",
         "0.19454830922947364",
         "0.0038945592994760287",
         "7.879004500926661"
        ],
        [
         "11",
         "ChromiteEFTA2022",
         "EFTA",
         "Chromite",
         "2022",
         "0.16394442511172666",
         "0.20543441226307382",
         "0.3070140864060876",
         "0.5339964267791847",
         "0.5130245099090981"
        ],
        [
         "12",
         "CobaltEFTA2022",
         "EFTA",
         "Cobalt",
         "2022",
         "0.24237470516675483",
         "31.392266113616607",
         "0.4928971158048766",
         "0.49173488217915196",
         "53.02698648001974"
        ],
        [
         "13",
         "Coking CoalEFTA2022",
         "EFTA",
         "Coking Coal",
         "2022",
         "0.18669575036848593",
         "0.05159330966766084",
         "0.3272799988428909",
         "0.5704465626636361",
         "0.11314113452728843"
        ],
        [
         "14",
         "CopperEFTA2022",
         "EFTA",
         "Copper",
         "2022",
         "0.06485465900629608",
         "0.27247212250390107",
         "0.10368441992479659",
         "0.6255005241224849",
         "1.7200555308032637"
        ],
        [
         "15",
         "DiatomiteEFTA2022",
         "EFTA",
         "Diatomite",
         "2022",
         "0.06142292939032208",
         "0.12226459592438292",
         "0.15162522238314766",
         "0.4050970440466039",
         "0.8149515034578835"
        ],
        [
         "16",
         "FeldsparEFTA2022",
         "EFTA",
         "Feldspar",
         "2022",
         "0.01811195438253869",
         "0.009985379381326829",
         "0.20066377210066477",
         "0.09026021086383579",
         "0.22571521123908728"
        ],
        [
         "17",
         "FluorsparEFTA2022",
         "EFTA",
         "Fluorspar",
         "2022",
         "0.16963438774096595",
         "0.23886786614941855",
         "0.42615798826202134",
         "0.39805516360910503",
         "0.5765080922863239"
        ],
        [
         "18",
         "GermaniumEFTA2022",
         "EFTA",
         "Germanium",
         "2022",
         "0.0",
         "0.0",
         "0.8764039128409503",
         "0.0",
         "0.0"
        ],
        [
         "19",
         "GoldEFTA2022",
         "EFTA",
         "Gold",
         "2022",
         "0.03171508035124381",
         "349.87922605636226",
         "0.049356777146401465",
         "0.6425678941145394",
         "4516.623757444646"
        ],
        [
         "20",
         "GraphiteEFTA2022",
         "EFTA",
         "Graphite",
         "2022",
         "0.01711435390432075",
         "0.07094955344389377",
         "0.470663478647389",
         "0.03636218801914405",
         "1.697269204384901"
        ],
        [
         "21",
         "GypsumEFTA2022",
         "EFTA",
         "Gypsum",
         "2022",
         "0.010491678078868834",
         "0.0010961695183042902",
         "0.07039292364592355",
         "0.14904449958126448",
         "0.04277542549657466"
        ],
        [
         "22",
         "IronEFTA2022",
         "EFTA",
         "Iron",
         "2022",
         "0.0449167052173681",
         "0.0074582406186944105",
         "0.20252183624846373",
         "0.2217869739353048",
         "0.06798139498024257"
        ],
        [
         "23",
         "KaolinEFTA2022",
         "EFTA",
         "Kaolin",
         "2022",
         "0.044045587278841655",
         "0.028618889454358636",
         "0.10187742563033231",
         "0.43233902904715543",
         "0.26601856448906047"
        ],
        [
         "24",
         "LeadEFTA2022",
         "EFTA",
         "Lead",
         "2022",
         "0.12485645949545933",
         "0.2996373830624757",
         "0.2016226144381781",
         "0.6192582109074032",
         "0.982531659365808"
        ],
        [
         "25",
         "LigniteEFTA2022",
         "EFTA",
         "Lignite",
         "2022",
         "0.033187872753357446",
         "0.02102830486846492",
         "0.08802223420123098",
         "0.3770396542933162",
         "0.2594098257403382"
        ],
        [
         "26",
         "LithiumEFTA2022",
         "EFTA",
         "Lithium",
         "2022",
         "0.13028903375032516",
         "11.856718315416545",
         "0.31981095428556255",
         "0.40739390569463957",
         "37.25788625021687"
        ],
        [
         "27",
         "MagnesiteEFTA2022",
         "EFTA",
         "Magnesite",
         "2022",
         "0.18296509021622046",
         "0.40444062016662885",
         "0.42040077556916244",
         "0.43521587220792335",
         "0.9049990159198592"
        ],
        [
         "28",
         "ManganeseEFTA2022",
         "EFTA",
         "Manganese",
         "2022",
         "0.11655075084071975",
         "0.0725512475789792",
         "0.2035183372902862",
         "0.5726793584918043",
         "0.2548539579378681"
        ],
        [
         "29",
         "MercuryEFTA2022",
         "EFTA",
         "Mercury",
         "2022",
         "0.20150896928274403",
         "0.9947366992843442",
         "0.49775437404450484",
         "0.40483615974156534",
         "2.021041971418926"
        ],
        [
         "30",
         "MolybdenumEFTA2022",
         "EFTA",
         "Molybdenum",
         "2022",
         "0.10860639780380967",
         "3.8471721302814363",
         "0.2326102658434335",
         "0.46690285749000865",
         "14.502663886958533"
        ],
        [
         "31",
         "Natural gasEFTA2022",
         "EFTA",
         "Natural gas",
         "2022",
         "0.039935261001160176",
         "0.22395167854536369",
         "0.1038190611969056",
         "0.3846621279440974",
         "2.295933834516369"
        ],
        [
         "32",
         "NickelEFTA2022",
         "EFTA",
         "Nickel",
         "2022",
         "0.13074498276506735",
         "1.0225117821702758",
         "0.26749007657640966",
         "0.48878442310258746",
         "3.201878605585136"
        ],
        [
         "33",
         "NiobiumEFTA2022",
         "EFTA",
         "Niobium",
         "2022",
         "0.358070975055945",
         "15.974541044117625",
         "0.8692862183478102",
         "0.41191378339864254",
         "18.2650491031767"
        ],
        [
         "34",
         "PalladiumEFTA2022",
         "EFTA",
         "Palladium",
         "2022",
         "0.14962326142953078",
         "13764.01864132123",
         "0.3236120898438461",
         "0.4623537442674936",
         "37662.37545172291"
        ],
        [
         "35",
         "Crude oilEFTA2022",
         "EFTA",
         "Crude oil",
         "2022",
         "0.0025603123837769116",
         "0.004605048035660953",
         "0.08372461716439887",
         "0.03058016232847703",
         "0.7363813509273086"
        ],
        [
         "36",
         "PhosphateEFTA2022",
         "EFTA",
         "Phosphate",
         "2022",
         "0.07651966472799868",
         "0.07146915391591438",
         "0.2348754375481461",
         "0.32578827963785373",
         "0.38239055411169126"
        ],
        [
         "37",
         "PlatinumEFTA2022",
         "EFTA",
         "Platinum",
         "2022",
         "0.25560332495982974",
         "1692.7932477711988",
         "0.5620044925741473",
         "0.45480655108127455",
         "2711.4337187648866"
        ],
        [
         "38",
         "Rare earthEFTA2022",
         "EFTA",
         "Rare earth",
         "2022",
         "0.27038443362555176",
         "14.608028896864056",
         "0.5282617688739127",
         "0.5118379741958726",
         "22.119306555261375"
        ],
        [
         "39",
         "RhodiumEFTA2022",
         "EFTA",
         "Rhodium",
         "2022",
         "0.3453406323351461",
         "144036.49683729888",
         "0.699713407838737",
         "0.4935458267147237",
         "170760.1170212766"
        ],
        [
         "40",
         "SeleniumEFTA2022",
         "EFTA",
         "Selenium",
         "2022",
         "0.07576615323025908",
         "2.6706404290806645",
         "0.1970920899125283",
         "0.38442006101759313",
         "14.431177042801556"
        ],
        [
         "41",
         "SilverEFTA2022",
         "EFTA",
         "Silver",
         "2022",
         "0.07273240442517806",
         "44.590269066721575",
         "0.11857763803203183",
         "0.6133736987199102",
         "250.99999999999997"
        ],
        [
         "42",
         "Steam CoalEFTA2022",
         "EFTA",
         "Steam Coal",
         "2022",
         "0.2066976016605465",
         "0.07197484460996517",
         "0.3770712498410497",
         "0.5481659016636182",
         "0.14256301513358277"
        ],
        [
         "43",
         "SulfurEFTA2022",
         "EFTA",
         "Sulfur",
         "2022",
         "0.024522036745937142",
         "0.01681681507259486",
         "0.08458930789358836",
         "0.28989522856464756",
         "0.2807687593887412"
        ],
        [
         "44",
         "TantalumEFTA2022",
         "EFTA",
         "Tantalum",
         "2022",
         "0.09386880527252855",
         "132.9047085300583",
         "0.18845843476299362",
         "0.49808757772279333",
         "579.6697674418605"
        ],
        [
         "45",
         "TelluriumEFTA2022",
         "EFTA",
         "Tellurium",
         "2022",
         "0.24952349646521446",
         "156.37345612044538",
         "0.5563361300324952",
         "0.4485121188347771",
         "256.57430488974114"
        ],
        [
         "46",
         "TinEFTA2022",
         "EFTA",
         "Tin",
         "2022",
         "0.04510861425206603",
         "2.966012437070304",
         "0.13707362475950757",
         "0.32908310647805533",
         "26.92"
        ],
        [
         "47",
         "TitaniumEFTA2022",
         "EFTA",
         "Titanium",
         "2022",
         "0.048054749824551685",
         "0.0409909027947525",
         "0.17493243990142024",
         "0.27470462226235454",
         "0.34923095876376514"
        ],
        [
         "48",
         "TungstenEFTA2022",
         "EFTA",
         "Tungsten",
         "2022",
         "0.23277788334083047",
         "30.023826403386533",
         "0.6007017512773754",
         "0.3875099129407145",
         "52.80631949063956"
        ],
        [
         "49",
         "UraniumEFTA2022",
         "EFTA",
         "Uranium",
         "2022",
         "0.0",
         "0.0",
         "0.24703176337277888",
         "0.0",
         "0.0"
        ]
       ],
       "shape": {
        "columns": 9,
        "rows": 106
       }
      },
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>DBID</th>\n",
       "      <th>Country [Economic Entity]</th>\n",
       "      <th>Raw Material</th>\n",
       "      <th>Year</th>\n",
       "      <th>GeoPolRisk Score</th>\n",
       "      <th>GeoPolRisk Characterization Factor [eq. Kg-Cu/Kg]</th>\n",
       "      <th>HHI</th>\n",
       "      <th>Import Risk</th>\n",
       "      <th>Price</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>AluminiumEFTA2022</td>\n",
       "      <td>EFTA</td>\n",
       "      <td>Aluminium</td>\n",
       "      <td>2022</td>\n",
       "      <td>0.028892</td>\n",
       "      <td>0.250305</td>\n",
       "      <td>0.353279</td>\n",
       "      <td>0.081781</td>\n",
       "      <td>3.546990</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>AntimonyEFTA2022</td>\n",
       "      <td>EFTA</td>\n",
       "      <td>Antimony</td>\n",
       "      <td>2022</td>\n",
       "      <td>0.115442</td>\n",
       "      <td>0.011542</td>\n",
       "      <td>0.276644</td>\n",
       "      <td>0.417296</td>\n",
       "      <td>0.040934</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>ArsenicEFTA2022</td>\n",
       "      <td>EFTA</td>\n",
       "      <td>Arsenic</td>\n",
       "      <td>2022</td>\n",
       "      <td>0.164176</td>\n",
       "      <td>4.912686</td>\n",
       "      <td>0.393237</td>\n",
       "      <td>0.417499</td>\n",
       "      <td>12.250974</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>AsbestosEFTA2022</td>\n",
       "      <td>EFTA</td>\n",
       "      <td>Asbestos</td>\n",
       "      <td>2022</td>\n",
       "      <td>0.189662</td>\n",
       "      <td>0.236331</td>\n",
       "      <td>0.334918</td>\n",
       "      <td>0.566294</td>\n",
       "      <td>0.510155</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>BaryteEFTA2022</td>\n",
       "      <td>EFTA</td>\n",
       "      <td>Baryte</td>\n",
       "      <td>2022</td>\n",
       "      <td>0.070911</td>\n",
       "      <td>0.034209</td>\n",
       "      <td>0.151374</td>\n",
       "      <td>0.468447</td>\n",
       "      <td>0.197513</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",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>101</th>\n",
       "      <td>TungstenNAFTA2022</td>\n",
       "      <td>NAFTA</td>\n",
       "      <td>Tungsten</td>\n",
       "      <td>2022</td>\n",
       "      <td>0.228728</td>\n",
       "      <td>18.544553</td>\n",
       "      <td>0.600702</td>\n",
       "      <td>0.380767</td>\n",
       "      <td>33.193985</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>102</th>\n",
       "      <td>UraniumNAFTA2022</td>\n",
       "      <td>NAFTA</td>\n",
       "      <td>Uranium</td>\n",
       "      <td>2022</td>\n",
       "      <td>0.021769</td>\n",
       "      <td>5.251664</td>\n",
       "      <td>0.247032</td>\n",
       "      <td>0.088121</td>\n",
       "      <td>98.770603</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>103</th>\n",
       "      <td>VanadiumNAFTA2022</td>\n",
       "      <td>NAFTA</td>\n",
       "      <td>Vanadium</td>\n",
       "      <td>2022</td>\n",
       "      <td>0.214775</td>\n",
       "      <td>16.578472</td>\n",
       "      <td>0.502120</td>\n",
       "      <td>0.427737</td>\n",
       "      <td>31.602510</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>104</th>\n",
       "      <td>ZincNAFTA2022</td>\n",
       "      <td>NAFTA</td>\n",
       "      <td>Zinc</td>\n",
       "      <td>2022</td>\n",
       "      <td>0.010950</td>\n",
       "      <td>0.050845</td>\n",
       "      <td>0.138882</td>\n",
       "      <td>0.078843</td>\n",
       "      <td>1.901065</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>105</th>\n",
       "      <td>ZirconiumNAFTA2022</td>\n",
       "      <td>NAFTA</td>\n",
       "      <td>Zirconium</td>\n",
       "      <td>2022</td>\n",
       "      <td>0.071479</td>\n",
       "      <td>0.394452</td>\n",
       "      <td>0.194716</td>\n",
       "      <td>0.367096</td>\n",
       "      <td>2.259305</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>106 rows × 9 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                   DBID Country [Economic Entity] Raw Material  Year  \\\n",
       "0     AluminiumEFTA2022                      EFTA    Aluminium  2022   \n",
       "1      AntimonyEFTA2022                      EFTA     Antimony  2022   \n",
       "2       ArsenicEFTA2022                      EFTA      Arsenic  2022   \n",
       "3      AsbestosEFTA2022                      EFTA     Asbestos  2022   \n",
       "4        BaryteEFTA2022                      EFTA       Baryte  2022   \n",
       "..                  ...                       ...          ...   ...   \n",
       "101   TungstenNAFTA2022                     NAFTA     Tungsten  2022   \n",
       "102    UraniumNAFTA2022                     NAFTA      Uranium  2022   \n",
       "103   VanadiumNAFTA2022                     NAFTA     Vanadium  2022   \n",
       "104       ZincNAFTA2022                     NAFTA         Zinc  2022   \n",
       "105  ZirconiumNAFTA2022                     NAFTA    Zirconium  2022   \n",
       "\n",
       "     GeoPolRisk Score  GeoPolRisk Characterization Factor [eq. Kg-Cu/Kg]  \\\n",
       "0            0.028892                                           0.250305   \n",
       "1            0.115442                                           0.011542   \n",
       "2            0.164176                                           4.912686   \n",
       "3            0.189662                                           0.236331   \n",
       "4            0.070911                                           0.034209   \n",
       "..                ...                                                ...   \n",
       "101          0.228728                                          18.544553   \n",
       "102          0.021769                                           5.251664   \n",
       "103          0.214775                                          16.578472   \n",
       "104          0.010950                                           0.050845   \n",
       "105          0.071479                                           0.394452   \n",
       "\n",
       "          HHI  Import Risk      Price  \n",
       "0    0.353279     0.081781   3.546990  \n",
       "1    0.276644     0.417296   0.040934  \n",
       "2    0.393237     0.417499  12.250974  \n",
       "3    0.334918     0.566294   0.510155  \n",
       "4    0.151374     0.468447   0.197513  \n",
       "..        ...          ...        ...  \n",
       "101  0.600702     0.380767  33.193985  \n",
       "102  0.247032     0.088121  98.770603  \n",
       "103  0.502120     0.427737  31.602510  \n",
       "104  0.138882     0.078843   1.901065  \n",
       "105  0.194716     0.367096   2.259305  \n",
       "\n",
       "[106 rows x 9 columns]"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "gprs_calc(ListofYear, [\"EFTA\", \"NAFTA\"], ListofMetals)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
