2territory_iso_code = {
'Andorra':
'AD',
'The United Arab Emirates':
'AE',
'Afghanistan':
'AF',
'Antigua and Barbuda':
'AG',
'Anguilla':
'AI',
'Albania':
'AL',
3'Armenia':
'AM',
'Netherlands Antilles':
'AN',
'Angola':
'AO',
'Antarctica':
'AQ',
'Argentina':
'AR',
'American Samoa':
'AS',
'Austria':
'AT',
'Australia':
'AU',
4'Aruba':
'AW',
'Åland Islands':
'AX',
'Azerbaijan':
'AZ',
'Bosnia and Herzegovina':
'BA',
'Barbados':
'BB',
'Bangladesh':
'BD',
'Belgium':
'BE',
5'Burkina Faso':
'BF',
'Bulgaria':
'BG',
'Bahrain':
'BH',
'Burundi':
'BI',
'Benin':
'BJ',
'Saint Barthélemy':
'BL',
'Bermuda':
'BM',
'Brunei':
'BN',
6'Bolivia':
'BO',
'Bonaire, Sint Eustatius and Saba':
'BQ',
'Brazil':
'BR',
'The Bahamas':
'BS',
'Bhutan':
'BT',
'Bouvet Island':
'BV',
'Botswana':
'BW',
7'Belarus':
'BY',
'Belize':
'BZ',
'Canada':
'CA',
'Cocos Islands':
'CC',
'The Democratic Republic of the Congo':
'CD',
'The Central African Republic':
'CF',
8'The Congo':
'CG',
'Switzerland':
'CH',
"Côte d'Ivoire":
'CI',
'Cook Islands':
'CK',
'Chile':
'CL',
'Cameroon':
'CM',
'China':
'CN',
'Colombia':
'CO',
9'Costa Rica':
'CR',
'Serbia and Montenegro':
'CS',
'Cuba':
'CU',
'Cape Verde':
'CV',
'Curaçao':
'CW',
'Christmas Island':
'CX',
'Cyprus':
'CY',
'Czechia':
'CZ',
10'Germany':
'DE',
'Djibouti':
'DJ',
'Denmark':
'DK',
'Dominica':
'DM',
'The Dominican Republic':
'DO',
'Algeria':
'DZ',
'Ecuador':
'EC',
'Estonia':
'EE',
'Egypt':
11'EG',
'Western Sahara':
'EH',
'Eritrea':
'ER',
'Spain':
'ES',
'Ceuta, Spain':
'ES-CE',
'Canary Islands, Spain':
'ES-CN',
'Melilla, Spain':
'ES-ML',
'Ethiopia':
'ET',
12'Finland':
'FI',
'Fiji':
'FJ',
'Falkland Islands':
'FK',
'Micronesia':
'FM',
'Faroe Islands':
'FO',
'France':
'FR',
'Gabon':
'GA',
'The United Kingdom':
'GB',
13'Grenada':
'GD',
'Georgia':
'GE',
'French Guiana':
'GF',
'Guernsey':
'GG',
'Ghana':
'GH',
'Gibraltar':
'GI',
'Greenland':
'GL',
'The Gambia':
'GM',
'Guinea':
'GN',
14'Guadeloupe':
'GP',
'Equatorial Guinea':
'GQ',
'Greece':
'GR',
'South Georgia and The South Sandwich Islands':
'GS',
'Guatemala':
'GT',
'Guam':
'GU',
15'Guinea-Bissau':
'GW',
'Guyana':
'GY',
'Hong Kong':
'HK',
'Heard Island and McDonald Islands':
'HM',
'Honduras':
'HN',
'Croatia':
'HR',
'Haiti':
'HT',
16'Hungary':
'HU',
'Indonesia':
'ID',
'Ireland':
'IE',
'Israel':
'IL',
'Isle of Man':
'IM',
'India':
'IN',
'The British Indian Ocean Territory':
'IO',
'Iraq':
'IQ',
17'Iran':
'IR',
'Iceland':
'IS',
'Italy':
'IT',
'Jersey':
'JE',
'Jamaica':
'JM',
'Jordan':
'JO',
'Japan':
'JP',
'Kenya':
'KE',
'Kyrgyzstan':
'KG',
'Cambodia':
'KH',
18'Kiribati':
'KI',
'The Comoros':
'KM',
'Saint Kitts and Nevis':
'KN',
'Korea (North)':
'KP',
'Korea (South)':
'KR',
'Kuwait':
'KW',
'Cayman Islands':
'KY',
19'Kazakhstan':
'KZ',
'Laos':
'LA',
'Lebanon':
'LB',
'Saint Lucia':
'LC',
'Liechtenstein':
'LI',
'Sri Lanka':
'LK',
'Liberia':
'LR',
'Lesotho':
'LS',
20'Lithuania':
'LT',
'Luxembourg':
'LU',
'Latvia':
'LV',
'Libya':
'LY',
'Morocco':
'MA',
'Monaco':
'MC',
'Moldova':
'MD',
'Montenegro':
'ME',
'Saint Martin':
'MF',
21'Madagascar':
'MG',
'The Marshall Islands':
'MH',
'Macedonia':
'MK',
'Mali':
'ML',
'Myanmar':
'MM',
'Mongolia':
'MN',
'Macao':
'MO',
'Northern Mariana Islands':
'MP',
22'Martinique':
'MQ',
'Mauritania':
'MR',
'Montserrat':
'MS',
'Malta':
'MT',
'Mauritius':
'MU',
'Maldives':
'MV',
'Malawi':
'MW',
'Mexico':
'MX',
'Malaysia':
'MY',
23'Mozambique':
'MZ',
'Namibia':
'NA',
'New Caledonia':
'NC',
'The Niger':
'NE',
'Norfolk Island':
'NF',
'Nigeria':
'NG',
'Nicaragua':
'NI',
'The Netherlands':
'NL',
24'Norway':
'NO',
'Nepal':
'NP',
'Nauru':
'NR',
'Niue':
'NU',
'New Zealand':
'NZ',
'Oman':
'OM',
'Panama':
'PA',
'Peru':
'PE',
'French Polynesia':
'PF',
25'Papua New Guinea':
'PG',
'The Philippines':
'PH',
'Pakistan':
'PK',
'Poland':
'PL',
'Saint Pierre and Miquelon':
'PM',
'Pitcairn':
'PN',
'Puerto Rico':
'PR',
26'The Occupied Palestinian Territory':
'PS',
'Portugal':
'PT',
'Palau':
'PW',
'Paraguay':
'PY',
'Qatar':
'QA',
'Réunion':
'RE',
'Romania':
'RO',
'Serbia':
'RS',
27'Russia':
'RU',
'Rwanda':
'RW',
'Saudi Arabia':
'SA',
'Solomon Islands':
'SB',
'Seychelles':
'SC',
'The Sudan':
'SD',
'Sweden':
'SE',
'Singapore':
'SG',
28'Saint Helena':
'SH',
'Slovenia':
'SI',
'Svalbard and Jan Mayen':
'SJ',
'Slovakia':
'SK',
'Sierra Leone':
'SL',
'San Marino':
'SM',
'Senegal':
'SN',
'Somalia':
'SO',
29'Suriname':
'SR',
'South Soudan':
'SS',
'Sao Tome and Principe':
'ST',
'El Salvador':
'SV',
'Sint Maarten':
'SX',
'Syria':
'SY',
'Eswatini':
'SZ',
30'Turks and Caicos Islands':
'TC',
'Chad':
'TD',
'The French Southern Territories':
'TF',
'Togo':
'TG',
'Thailand':
'TH',
'Tajikistan':
'TJ',
'Tokelau':
'TK',
31'Timor-Leste':
'TL',
'Turkmenistan':
'TM',
'Tunisia':
'TN',
'Tonga':
'TO',
'Turkey':
'TR',
'Trinidad and Tobago':
'TT',
'Tuvalu':
'TV',
'Taiwan':
'TW',
32'Tanzania':
'TZ',
'Ukraine':
'UA',
'Uganda':
'UG',
'United States Minor Outlying Islands':
'UM',
'The United States':
'US',
'Uruguay':
'UY',
'Uzbekistan':
'UZ',
33'The Holy See':
'VA',
'Saint Vincent and The Grenadines':
'VC',
'Venezuela':
'VE',
'British Virgin Islands':
'VG',
'US Virgin Islands':
'VI',
'Viet Nam':
'VN',
34'Vanuatu':
'VU',
'Wallis and Futuna':
'WF',
'Samoa':
'WS',
'Yemen':
'YE',
'Mayotte':
'YT',
'South Africa':
'ZA',
'Zambia':
'ZM',
'Zimbabwe':
'ZW',
'Bahamas':
'BS',
35'Bolivia (Plurinational State of)':
'BO',
'Bosnia-Hercegovina':
'BA',
'British Indian Ocean Territory':
'IO',
'Brunei Darussalam':
'BN',
'Cabo Verde':
'CV',
36'Central African Republic':
'CF',
'China (PRC)':
'CN',
'Cocos (Keeling) Islands':
'CC',
'Comoros':
'KM',
'Congo':
'CG',
'Congo, Democratic Republic of the':
'CD',
37'Czech Republic':
'CZ',
'Dominican Republic':
'DO',
'Falkland Islands (Malvinas)':
'FK',
'French Southern Territories':
'TF',
'Gambia':
'GM',
'Holy See':
'VA',
38'Iran (Islamic Republic of)':
'IR',
'Kyrgyz Republic':
'KG',
"Lao People's Democratic Republic":
'LA',
'North Macedonia':
'MK',
'Marshall Islands':
'MH',
39'Netherlands':
'NL',
'Niger':
'NE',
'Palestine, State of':
'PS',
'Philippines':
'PH',
'Saint Helena, Ascension and Tristan da Cunha':
'SH',
40'Saint Martin (French part)':
'MF',
'Saint Vincent and the Grenadines':
'VC',
'Sint Maarten (Dutch part)':
'SX',
'Slovak Republic':
'SK',
41'South Georgia and the South Sandwich Islands':
'GS',
'South Sudan':
'SS',
'Sudan':
'SD',
'Syrian Arab Republic':
'SY',
'Tanzania, United Republic of':
'TZ',
42'USA':
'US',
'United Arab Emirates':
'AE',
'United Kingdom':
'GB',
'United States of America':
'US',
'Vietnam':
'VN',
'Virgin Islands (British)':
'VG',
43'Virgin Islands (U.S.)':
'VI',
'Zanzibar':
'TZ'}
47 Maps the full country name to ISO-2 code
50 """Takes each country name and searches their ISO-2 code in the territory_iso_code
53 country (str): current country
54 iso (dict): ISO codes for countries
60 """Applies terr_iso for all territory column
63 df (pandas dataframe): current file loaded as dataframe
64 territory_iso_code (dict): ISO codes for countries
65 Returns: df (pandas dataframe)
67 df[
"Territory"] = df.apply(
lambda Row: self.
terr_iso(Row[
'Territory'], territory_iso_code), axis=1)
territory_code(self, df, territory_iso_code=territory_iso_code)
terr_iso(self, country, iso)