Skip to content

Instantly share code, notes, and snippets.

@fuzzy-focus
Last active October 11, 2018 20:57
Show Gist options
  • Save fuzzy-focus/9505fea7d299ade9e2ef27c54850b0cf to your computer and use it in GitHub Desktop.
Save fuzzy-focus/9505fea7d299ade9e2ef27c54850b0cf to your computer and use it in GitHub Desktop.
Trivia List generator
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"import re\n",
"import unicodedata"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Links\n",
"- done\n",
" - https://en.wikipedia.org/wiki/List_of_national_capitals\n",
" - https://en.wikipedia.org/wiki/List_of_elevation_extremes_by_country\n",
" - https://en.wikipedia.org/wiki/List_of_countries_and_dependencies_by_area\n",
" - https://en.wikipedia.org/wiki/List_of_countries_and_territories_by_land_borders\n",
"- todo\n",
" - https://en.wikipedia.org/wiki/List_of_official_languages_by_country_and_territory\n",
" - https://en.wikipedia.org/wiki/List_of_current_heads_of_state_and_government\n",
" - https://en.wikipedia.org/wiki/List_of_time_zones_by_country\n",
" - https://en.wikipedia.org/wiki/List_of_highest_mountains_on_Earth\n",
" - https://en.wikipedia.org/wiki/List_of_rivers_by_length\n",
" - https://en.wikipedia.org/wiki/National_Football_League#Teams\n",
" - https://en.wikipedia.org/wiki/Major_League_Baseball#Teams\n",
" - https://en.wikipedia.org/wiki/National_Basketball_Association#Teams\n",
" - https://en.wikipedia.org/wiki/List_of_Tour_de_France_general_classification_winners#Winners\n",
" - https://en.wikipedia.org/wiki/List_of_popes\n",
" - https://en.wikipedia.org/wiki/List_of_Academy_Award-winning_films\n",
" - https://en.wikipedia.org/wiki/List_of_Presidents_of_the_United_States\n",
" - https://en.wikipedia.org/wiki/List_of_High_Kings_of_Ireland\n",
" - https://en.wikipedia.org/wiki/List_of_English_monarchs\n",
" - https://en.wikipedia.org/wiki/List_of_British_monarchs\n",
" - https://en.wikipedia.org/wiki/List_of_Scottish_monarchs\n",
"- on hold\n",
" - https://en.wikipedia.org/wiki/List_of_countries_by_spoken_languages\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"def thing():\n",
" page = ''\n",
" wikitables = pd.read_html(page,\n",
" attrs={\"class\":\"wikitable\"},\n",
" index_col=0,\n",
" skiprows=(1,),\n",
" header=0,\n",
" )\n",
" w = wikitables[0]\n",
" w.sort_index(inplace=True)\n",
" return w"
]
},
{
"cell_type": "code",
"execution_count": 90,
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style>\n",
" .dataframe thead tr:only-child th {\n",
" text-align: right;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: left;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>len (km)</th>\n",
" <th>len (mi)</th>\n",
" <th>#borders</th>\n",
" <th>#neighbours</th>\n",
" <th>neighbours</th>\n",
" </tr>\n",
" <tr>\n",
" <th>Country or territory (Territories without full sovereignty in italics) [2]</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>Adélie Land[4][5] (France)</th>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>2</td>\n",
" <td>1</td>\n",
" <td>Includes:  Australian Antarctic Territory[4] (...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Afghanistan</th>\n",
" <td>5529.0</td>\n",
" <td>3436</td>\n",
" <td>6 (7)</td>\n",
" <td>6</td>\n",
" <td>Includes:  People's Republic of China: 76 km (...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Akrotiri and Dhekelia[6] (United Kingdom)</th>\n",
" <td>152.0</td>\n",
" <td>94</td>\n",
" <td>6[7]</td>\n",
" <td>1</td>\n",
" <td>Includes:  Cyprus (5):[7]</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Åland Islands (Finland)</th>\n",
" <td>0.5</td>\n",
" <td>0.31</td>\n",
" <td>2</td>\n",
" <td>0</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Albania</th>\n",
" <td>720.0</td>\n",
" <td>450</td>\n",
" <td>4</td>\n",
" <td>4</td>\n",
" <td>Includes:  Greece: 282 km (175 mi) Kosovo:[8] ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Algeria</th>\n",
" <td>6343.0</td>\n",
" <td>3941</td>\n",
" <td>7</td>\n",
" <td>7</td>\n",
" <td>Includes:  Libya: 982 km (610 mi) Mali: 1,376 ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>American Samoa[10] (United States)</th>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Amsterdam Island and Île Saint-Paul[5] (France)</th>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Andorra</th>\n",
" <td>120.0</td>\n",
" <td>75</td>\n",
" <td>2</td>\n",
" <td>2</td>\n",
" <td>Includes:  France: 56.6 km (35.2 mi) Spain: 63...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Angola</th>\n",
" <td>5198.0</td>\n",
" <td>3230</td>\n",
" <td>5</td>\n",
" <td>4</td>\n",
" <td>Includes:  Democratic Republic of the Congo (2...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Anguilla[6] (United Kingdom)</th>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Antártica Chilena Province[4] (Chile)</th>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>2</td>\n",
" <td>2</td>\n",
" <td>Includes:  Argentine Antarctica[4][12] (Argent...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Antigua and Barbuda</th>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Argentina</th>\n",
" <td>9665.0</td>\n",
" <td>6006</td>\n",
" <td>6</td>\n",
" <td>5</td>\n",
" <td>Includes:  Bolivia: 832 km (517 mi) Brazil: 1,...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Argentine Antarctica[4] (Argentina)</th>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>2</td>\n",
" <td>2</td>\n",
" <td>Includes:  Antártica Chilena Province[4][12] (...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Armenia</th>\n",
" <td>1254.0</td>\n",
" <td>779</td>\n",
" <td>5</td>\n",
" <td>4</td>\n",
" <td>Includes:  Azerbaijan (6): 787 km (489 mi)[14]...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Aruba[15] (Netherlands)</th>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Ashmore and Cartier Islands[16] (Australia)</th>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Australia</th>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Australian Antarctic Territory[4] (Australia)</th>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>4</td>\n",
" <td>3</td>\n",
" <td>Includes:  Adélie Land[4] (France) (2) Queen M...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Austria</th>\n",
" <td>2562.0</td>\n",
" <td>1592</td>\n",
" <td>9</td>\n",
" <td>8</td>\n",
" <td>Includes:  Czech Republic: 362 km (225 mi) Ger...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Azerbaijan</th>\n",
" <td>2013.0</td>\n",
" <td>1251</td>\n",
" <td>7</td>\n",
" <td>5</td>\n",
" <td>Includes:  Armenia (6): 787 km (489 mi)[14] Ge...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Azores[19] (Portugal)</th>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Bahamas</th>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Bahrain</th>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Baker Island[10] and Howland Island[10] (United States)</th>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Bangladesh</th>\n",
" <td>4246.0</td>\n",
" <td>2638</td>\n",
" <td>3</td>\n",
" <td>2</td>\n",
" <td>Includes:  India (2), including Dahagram-Angar...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Barbados</th>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Bassas da India, Europa Island, and Juan de Nova Island[5][21] (France)</th>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Belarus</th>\n",
" <td>2900.0</td>\n",
" <td>1800</td>\n",
" <td>5</td>\n",
" <td>5</td>\n",
" <td>Includes:  Latvia: 141 km (88 mi) Lithuania: 5...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Tokelau[69] (New Zealand)</th>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Tonga</th>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Transnistria[70]</th>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>2</td>\n",
" <td>2</td>\n",
" <td>Includes:  Moldova Ukraine</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Tromelin Island[5][71] (France)</th>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Trinidad and Tobago</th>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Tunisia</th>\n",
" <td>1424.0</td>\n",
" <td>885</td>\n",
" <td>2</td>\n",
" <td>2</td>\n",
" <td>Includes:  Algeria: 965 km (600 mi) Libya: 459...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Turkey</th>\n",
" <td>2648.0</td>\n",
" <td>1645</td>\n",
" <td>9</td>\n",
" <td>8</td>\n",
" <td>Includes:  Armenia: 268 km (167 mi) Azerbaijan...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Turkmenistan</th>\n",
" <td>3736.0</td>\n",
" <td>2321</td>\n",
" <td>4</td>\n",
" <td>4</td>\n",
" <td>Includes:  Afghanistan: 744 km (462 mi) Iran: ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Turks and Caicos Islands[6] (United Kingdom)</th>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Tuvalu</th>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Uganda</th>\n",
" <td>2698.0</td>\n",
" <td>1676</td>\n",
" <td>5</td>\n",
" <td>5</td>\n",
" <td>Includes:  Democratic Republic of the Congo: 7...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Ukraine</th>\n",
" <td>4663.0</td>\n",
" <td>2897</td>\n",
" <td>8</td>\n",
" <td>7</td>\n",
" <td>Includes:  Belarus: 891 km (554 mi) Hungary: 1...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>United Arab Emirates</th>\n",
" <td>867.0</td>\n",
" <td>539</td>\n",
" <td>5 (6)</td>\n",
" <td>2 (3)</td>\n",
" <td>Includes:  Oman (4): 410 km (250 mi) Saudi Ara...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>United Kingdom[72]</th>\n",
" <td>499.0</td>\n",
" <td>310</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>Includes:  Ireland: 499 km (310 mi)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>United Kingdom (plus British overseas territories and Crown dependencies) →including: → Akrotiri and Dhekelia→ Anguilla→ Bermuda→ British Indian Ocean Territory→ British Virgin Islands→ Cayman Islands→ Falkland Islands→ Gibraltar→ Guernsey→ Isle of Man→ Jersey→ Montserrat→ Pitcairn Islands→ Saint Helena, Ascension and Tristan da Cunha→ South Georgia and the South Sandwich Islands→ Turks and Caicos Islands</th>\n",
" <td>513.0</td>\n",
" <td>319</td>\n",
" <td>7</td>\n",
" <td>3</td>\n",
" <td>Includes:  Cyprus (5):[7] 152 km (94 mi) Irela...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>United States</th>\n",
" <td>12034.0</td>\n",
" <td>7478</td>\n",
" <td>5</td>\n",
" <td>2</td>\n",
" <td>Includes:  Canada (4): 8,893 km (5,526 mi)[27]...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>United States Virgin Islands[10] (United States)</th>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Uruguay</th>\n",
" <td>1564.0</td>\n",
" <td>972</td>\n",
" <td>2</td>\n",
" <td>2</td>\n",
" <td>Includes:  Argentina: 579 km (360 mi) Brazil: ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Uzbekistan</th>\n",
" <td>6221.0</td>\n",
" <td>3866</td>\n",
" <td>5</td>\n",
" <td>5</td>\n",
" <td>Includes:  Afghanistan: 137 km (85 mi) Kazakhs...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Vanuatu</th>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Vatican City</th>\n",
" <td>3.2</td>\n",
" <td>2.0</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>Includes:  Italy: 3.2 km (2.0 mi)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Venezuela</th>\n",
" <td>4993.0</td>\n",
" <td>3103</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>Includes:  Brazil: 2,200 km (1,400 mi) Colombi...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Vietnam</th>\n",
" <td>4639.0</td>\n",
" <td>2883</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>Includes:  Cambodia: 1,228 km (763 mi) People'...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Wake Island[73] (United States)</th>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Wallis and Futuna[45] (France)</th>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>West Bank (Palestine)[38]</th>\n",
" <td>404.0</td>\n",
" <td>251</td>\n",
" <td>2</td>\n",
" <td>2</td>\n",
" <td>Includes:  Israel: 307 km (191 mi) Jordan: 97 ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Western Sahara[9]</th>\n",
" <td>2046.0</td>\n",
" <td>1271</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>Includes:  Algeria: 42 km (26 mi) Mauritania: ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Yemen</th>\n",
" <td>1746.0</td>\n",
" <td>1085</td>\n",
" <td>2</td>\n",
" <td>2</td>\n",
" <td>Includes:  Oman: 288 km (179 mi) Saudi Arabia:...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Zambia</th>\n",
" <td>5667.0</td>\n",
" <td>3521</td>\n",
" <td>8</td>\n",
" <td>8</td>\n",
" <td>Includes:  Angola: 1,110 km (690 mi) Botswana:...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Zimbabwe</th>\n",
" <td>3066.0</td>\n",
" <td>1905</td>\n",
" <td>4</td>\n",
" <td>4</td>\n",
" <td>Includes:  Botswana: 813 km (505 mi) Mozambiqu...</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>288 rows × 5 columns</p>\n",
"</div>"
],
"text/plain": [
" len (km) len (mi) \\\n",
"Country or territory (Territories without full ... \n",
"Adélie Land[4][5] (France) 0.0 0 \n",
"Afghanistan 5529.0 3436 \n",
"Akrotiri and Dhekelia[6] (United Kingdom) 152.0 94 \n",
"Åland Islands (Finland) 0.5 0.31 \n",
"Albania 720.0 450 \n",
"Algeria 6343.0 3941 \n",
"American Samoa[10] (United States) 0.0 0 \n",
"Amsterdam Island and Île Saint-Paul[5] (France) 0.0 0 \n",
"Andorra 120.0 75 \n",
"Angola 5198.0 3230 \n",
"Anguilla[6] (United Kingdom) 0.0 0 \n",
"Antártica Chilena Province[4] (Chile) 0.0 0 \n",
"Antigua and Barbuda 0.0 0 \n",
"Argentina 9665.0 6006 \n",
"Argentine Antarctica[4] (Argentina) 0.0 0 \n",
"Armenia 1254.0 779 \n",
"Aruba[15] (Netherlands) 0.0 0 \n",
"Ashmore and Cartier Islands[16] (Australia) 0.0 0 \n",
"Australia 0.0 0 \n",
"Australian Antarctic Territory[4] (Australia) 0.0 0 \n",
"Austria 2562.0 1592 \n",
"Azerbaijan 2013.0 1251 \n",
"Azores[19] (Portugal) 0.0 0 \n",
"Bahamas 0.0 0 \n",
"Bahrain 0.0 0 \n",
"Baker Island[10] and Howland Island[10] (United... 0.0 0 \n",
"Bangladesh 4246.0 2638 \n",
"Barbados 0.0 0 \n",
"Bassas da India, Europa Island, and Juan de Nov... 0.0 0 \n",
"Belarus 2900.0 1800 \n",
"... ... ... \n",
"Tokelau[69] (New Zealand) 0.0 0 \n",
"Tonga 0.0 0 \n",
"Transnistria[70] 0.0 0 \n",
"Tromelin Island[5][71] (France) 0.0 0 \n",
"Trinidad and Tobago 0.0 0 \n",
"Tunisia 1424.0 885 \n",
"Turkey 2648.0 1645 \n",
"Turkmenistan 3736.0 2321 \n",
"Turks and Caicos Islands[6] (United Kingdom) 0.0 0 \n",
"Tuvalu 0.0 0 \n",
"Uganda 2698.0 1676 \n",
"Ukraine 4663.0 2897 \n",
"United Arab Emirates 867.0 539 \n",
"United Kingdom[72] 499.0 310 \n",
"United Kingdom (plus British overseas territori... 513.0 319 \n",
"United States 12034.0 7478 \n",
"United States Virgin Islands[10] (United States) 0.0 0 \n",
"Uruguay 1564.0 972 \n",
"Uzbekistan 6221.0 3866 \n",
"Vanuatu 0.0 0 \n",
"Vatican City 3.2 2.0 \n",
"Venezuela 4993.0 3103 \n",
"Vietnam 4639.0 2883 \n",
"Wake Island[73] (United States) 0.0 0 \n",
"Wallis and Futuna[45] (France) 0.0 0 \n",
"West Bank (Palestine)[38] 404.0 251 \n",
"Western Sahara[9] 2046.0 1271 \n",
"Yemen 1746.0 1085 \n",
"Zambia 5667.0 3521 \n",
"Zimbabwe 3066.0 1905 \n",
"\n",
" #borders #neighbours \\\n",
"Country or territory (Territories without full ... \n",
"Adélie Land[4][5] (France) 2 1 \n",
"Afghanistan 6 (7) 6 \n",
"Akrotiri and Dhekelia[6] (United Kingdom) 6[7] 1 \n",
"Åland Islands (Finland) 2 0 \n",
"Albania 4 4 \n",
"Algeria 7 7 \n",
"American Samoa[10] (United States) 0 0 \n",
"Amsterdam Island and Île Saint-Paul[5] (France) 0 0 \n",
"Andorra 2 2 \n",
"Angola 5 4 \n",
"Anguilla[6] (United Kingdom) 0 0 \n",
"Antártica Chilena Province[4] (Chile) 2 2 \n",
"Antigua and Barbuda 0 0 \n",
"Argentina 6 5 \n",
"Argentine Antarctica[4] (Argentina) 2 2 \n",
"Armenia 5 4 \n",
"Aruba[15] (Netherlands) 0 0 \n",
"Ashmore and Cartier Islands[16] (Australia) 0 0 \n",
"Australia 0 0 \n",
"Australian Antarctic Territory[4] (Australia) 4 3 \n",
"Austria 9 8 \n",
"Azerbaijan 7 5 \n",
"Azores[19] (Portugal) 0 0 \n",
"Bahamas 0 0 \n",
"Bahrain 0 0 \n",
"Baker Island[10] and Howland Island[10] (United... 0 0 \n",
"Bangladesh 3 2 \n",
"Barbados 0 0 \n",
"Bassas da India, Europa Island, and Juan de Nov... 0 0 \n",
"Belarus 5 5 \n",
"... ... ... \n",
"Tokelau[69] (New Zealand) 0 0 \n",
"Tonga 0 0 \n",
"Transnistria[70] 2 2 \n",
"Tromelin Island[5][71] (France) 0 0 \n",
"Trinidad and Tobago 0 0 \n",
"Tunisia 2 2 \n",
"Turkey 9 8 \n",
"Turkmenistan 4 4 \n",
"Turks and Caicos Islands[6] (United Kingdom) 0 0 \n",
"Tuvalu 0 0 \n",
"Uganda 5 5 \n",
"Ukraine 8 7 \n",
"United Arab Emirates 5 (6) 2 (3) \n",
"United Kingdom[72] 1 1 \n",
"United Kingdom (plus British overseas territori... 7 3 \n",
"United States 5 2 \n",
"United States Virgin Islands[10] (United States) 0 0 \n",
"Uruguay 2 2 \n",
"Uzbekistan 5 5 \n",
"Vanuatu 0 0 \n",
"Vatican City 1 1 \n",
"Venezuela 3 3 \n",
"Vietnam 3 3 \n",
"Wake Island[73] (United States) 0 0 \n",
"Wallis and Futuna[45] (France) 0 0 \n",
"West Bank (Palestine)[38] 2 2 \n",
"Western Sahara[9] 3 3 \n",
"Yemen 2 2 \n",
"Zambia 8 8 \n",
"Zimbabwe 4 4 \n",
"\n",
" neighbours \n",
"Country or territory (Territories without full ... \n",
"Adélie Land[4][5] (France) Includes:  Australian Antarctic Territory[4] (... \n",
"Afghanistan Includes:  People's Republic of China: 76 km (... \n",
"Akrotiri and Dhekelia[6] (United Kingdom) Includes:  Cyprus (5):[7] \n",
"Åland Islands (Finland) NaN \n",
"Albania Includes:  Greece: 282 km (175 mi) Kosovo:[8] ... \n",
"Algeria Includes:  Libya: 982 km (610 mi) Mali: 1,376 ... \n",
"American Samoa[10] (United States) NaN \n",
"Amsterdam Island and Île Saint-Paul[5] (France) NaN \n",
"Andorra Includes:  France: 56.6 km (35.2 mi) Spain: 63... \n",
"Angola Includes:  Democratic Republic of the Congo (2... \n",
"Anguilla[6] (United Kingdom) NaN \n",
"Antártica Chilena Province[4] (Chile) Includes:  Argentine Antarctica[4][12] (Argent... \n",
"Antigua and Barbuda NaN \n",
"Argentina Includes:  Bolivia: 832 km (517 mi) Brazil: 1,... \n",
"Argentine Antarctica[4] (Argentina) Includes:  Antártica Chilena Province[4][12] (... \n",
"Armenia Includes:  Azerbaijan (6): 787 km (489 mi)[14]... \n",
"Aruba[15] (Netherlands) NaN \n",
"Ashmore and Cartier Islands[16] (Australia) NaN \n",
"Australia NaN \n",
"Australian Antarctic Territory[4] (Australia) Includes:  Adélie Land[4] (France) (2) Queen M... \n",
"Austria Includes:  Czech Republic: 362 km (225 mi) Ger... \n",
"Azerbaijan Includes:  Armenia (6): 787 km (489 mi)[14] Ge... \n",
"Azores[19] (Portugal) NaN \n",
"Bahamas NaN \n",
"Bahrain NaN \n",
"Baker Island[10] and Howland Island[10] (United... NaN \n",
"Bangladesh Includes:  India (2), including Dahagram-Angar... \n",
"Barbados NaN \n",
"Bassas da India, Europa Island, and Juan de Nov... NaN \n",
"Belarus Includes:  Latvia: 141 km (88 mi) Lithuania: 5... \n",
"... ... \n",
"Tokelau[69] (New Zealand) NaN \n",
"Tonga NaN \n",
"Transnistria[70] Includes:  Moldova Ukraine \n",
"Tromelin Island[5][71] (France) NaN \n",
"Trinidad and Tobago NaN \n",
"Tunisia Includes:  Algeria: 965 km (600 mi) Libya: 459... \n",
"Turkey Includes:  Armenia: 268 km (167 mi) Azerbaijan... \n",
"Turkmenistan Includes:  Afghanistan: 744 km (462 mi) Iran: ... \n",
"Turks and Caicos Islands[6] (United Kingdom) NaN \n",
"Tuvalu NaN \n",
"Uganda Includes:  Democratic Republic of the Congo: 7... \n",
"Ukraine Includes:  Belarus: 891 km (554 mi) Hungary: 1... \n",
"United Arab Emirates Includes:  Oman (4): 410 km (250 mi) Saudi Ara... \n",
"United Kingdom[72] Includes:  Ireland: 499 km (310 mi) \n",
"United Kingdom (plus British overseas territori... Includes:  Cyprus (5):[7] 152 km (94 mi) Irela... \n",
"United States Includes:  Canada (4): 8,893 km (5,526 mi)[27]... \n",
"United States Virgin Islands[10] (United States) NaN \n",
"Uruguay Includes:  Argentina: 579 km (360 mi) Brazil: ... \n",
"Uzbekistan Includes:  Afghanistan: 137 km (85 mi) Kazakhs... \n",
"Vanuatu NaN \n",
"Vatican City Includes:  Italy: 3.2 km (2.0 mi) \n",
"Venezuela Includes:  Brazil: 2,200 km (1,400 mi) Colombi... \n",
"Vietnam Includes:  Cambodia: 1,228 km (763 mi) People'... \n",
"Wake Island[73] (United States) NaN \n",
"Wallis and Futuna[45] (France) NaN \n",
"West Bank (Palestine)[38] Includes:  Israel: 307 km (191 mi) Jordan: 97 ... \n",
"Western Sahara[9] Includes:  Algeria: 42 km (26 mi) Mauritania: ... \n",
"Yemen Includes:  Oman: 288 km (179 mi) Saudi Arabia:... \n",
"Zambia Includes:  Angola: 1,110 km (690 mi) Botswana:... \n",
"Zimbabwe Includes:  Botswana: 813 km (505 mi) Mozambiqu... \n",
"\n",
"[288 rows x 5 columns]"
]
},
"execution_count": 90,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"def borders():\n",
" page = \"https://en.wikipedia.org/wiki/List_of_countries_and_territories_by_land_borders\"\n",
" h = [\"len (km)\", \"len (mi)\",\"#borders\", \"#neighbours\", \"neighbours\"]\n",
" wikitables = pd.read_html(page,\n",
" index_col=0,\n",
" attrs={\"class\":\"wikitable\"},\n",
" parse_dates=False,\n",
" skiprows=(1,),\n",
" header=0)\n",
" w = wikitables[0]\n",
" w.columns = h\n",
" return w\n",
"\n",
"b = borders()\n",
"#print(b['neighbours'].loc['Venezuela':'Vietnam'])\n",
"b"
]
},
{
"cell_type": "code",
"execution_count": 89,
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style>\n",
" .dataframe thead tr:only-child th {\n",
" text-align: right;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: left;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>City</th>\n",
" <th>Notes</th>\n",
" </tr>\n",
" <tr>\n",
" <th>Country</th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>Abkhazia</th>\n",
" <td>Sukhumi</td>\n",
" <td>De facto independent state recognised by Russi...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Afghanistan</th>\n",
" <td>Kabul</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Akrotiri and Dhekelia</th>\n",
" <td>Episkopi Cantonment</td>\n",
" <td>British Overseas Territory</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Albania</th>\n",
" <td>Tirana</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Algeria</th>\n",
" <td>Algiers</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>American Samoa</th>\n",
" <td>Pago Pago</td>\n",
" <td>Territory of the United States</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Andorra</th>\n",
" <td>Andorra la Vella</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Angola</th>\n",
" <td>Luanda</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Anguilla</th>\n",
" <td>The Valley</td>\n",
" <td>British Overseas Territory</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Antigua and Barbuda</th>\n",
" <td>St. John's</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Argentina</th>\n",
" <td>Buenos Aires</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Armenia</th>\n",
" <td>Yerevan</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Artsakh</th>\n",
" <td>Stepanakert</td>\n",
" <td>The self-declared country remains diplomatical...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Aruba</th>\n",
" <td>Oranjestad</td>\n",
" <td>Self-governing country within the Kingdom of t...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Ascension Island</th>\n",
" <td>Georgetown</td>\n",
" <td>Part of the British Overseas Territory of Sain...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Australia</th>\n",
" <td>Canberra</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Austria</th>\n",
" <td>Vienna</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Azerbaijan</th>\n",
" <td>Baku</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Bahamas</th>\n",
" <td>Nassau</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Bahrain</th>\n",
" <td>Manama</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Bangladesh</th>\n",
" <td>Dhaka</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Barbados</th>\n",
" <td>Bridgetown</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Belarus</th>\n",
" <td>Minsk</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Belgium</th>\n",
" <td>Brussels</td>\n",
" <td>Also the de facto capital of the European Union</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Belize</th>\n",
" <td>Belmopan</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Benin</th>\n",
" <td>Porto-Novo (official)Cotonou (de facto)</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Bermuda</th>\n",
" <td>Hamilton</td>\n",
" <td>British Overseas Territory</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Bhutan</th>\n",
" <td>Thimphu</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Bolivia</th>\n",
" <td>Sucre (constitutional)La Paz (administrative)</td>\n",
" <td>La Paz is the highest administrative capital (...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Bosnia and Herzegovina</th>\n",
" <td>Sarajevo</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Taiwan</th>\n",
" <td>Taipei</td>\n",
" <td>Officially the Republic of China (ROC), it has...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Tajikistan</th>\n",
" <td>Dushanbe</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Tanzania</th>\n",
" <td>Dodoma (official, legislative)</td>\n",
" <td>Dar es Salaam, the former capital and largest ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Thailand</th>\n",
" <td>Bangkok</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Togo</th>\n",
" <td>Lomé</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Tonga</th>\n",
" <td>Nukuʻalofa</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Transnistria</th>\n",
" <td>Tiraspol</td>\n",
" <td>De facto independent state, not recognized by ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Trinidad and Tobago</th>\n",
" <td>Port of Spain</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Tristan da Cunha</th>\n",
" <td>Edinburgh of the Seven Seas</td>\n",
" <td>Part of the British Overseas Territory of Sain...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Tunisia</th>\n",
" <td>Tunis</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Turkey</th>\n",
" <td>Ankara</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Turkmenistan</th>\n",
" <td>Ashgabat</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Turks and Caicos Islands</th>\n",
" <td>Cockburn Town</td>\n",
" <td>British Overseas Territory</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Tuvalu</th>\n",
" <td>Funafuti</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Uganda</th>\n",
" <td>Kampala</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Ukraine</th>\n",
" <td>Kiev</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>United Arab Emirates</th>\n",
" <td>Abu Dhabi</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>United Kingdom</th>\n",
" <td>London</td>\n",
" <td>Prior to the Acts of Union in 1707, London was...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>United States</th>\n",
" <td>Washington</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>United States Virgin Islands</th>\n",
" <td>Charlotte Amalie</td>\n",
" <td>Territory of the U.S.</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Uruguay</th>\n",
" <td>Montevideo</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Uzbekistan</th>\n",
" <td>Tashkent</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Vanuatu</th>\n",
" <td>Port Vila</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Vatican City</th>\n",
" <td>Vatican City</td>\n",
" <td>City-state</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Venezuela</th>\n",
" <td>Caracas</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Vietnam</th>\n",
" <td>Hanoi</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Wallis and Futuna</th>\n",
" <td>Mata-Utu</td>\n",
" <td>Overseas collectivity of France</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Yemen</th>\n",
" <td>Sana'a (de jure)</td>\n",
" <td>Sana'a has been occupied by Houthis rebels sin...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Zambia</th>\n",
" <td>Lusaka</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Zimbabwe</th>\n",
" <td>Harare</td>\n",
" <td></td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>243 rows × 2 columns</p>\n",
"</div>"
],
"text/plain": [
" City \\\n",
"Country \n",
"Abkhazia Sukhumi \n",
"Afghanistan Kabul \n",
"Akrotiri and Dhekelia Episkopi Cantonment \n",
"Albania Tirana \n",
"Algeria Algiers \n",
"American Samoa Pago Pago \n",
"Andorra Andorra la Vella \n",
"Angola Luanda \n",
"Anguilla The Valley \n",
"Antigua and Barbuda St. John's \n",
"Argentina Buenos Aires \n",
"Armenia Yerevan \n",
"Artsakh Stepanakert \n",
"Aruba Oranjestad \n",
"Ascension Island Georgetown \n",
"Australia Canberra \n",
"Austria Vienna \n",
"Azerbaijan Baku \n",
"Bahamas Nassau \n",
"Bahrain Manama \n",
"Bangladesh Dhaka \n",
"Barbados Bridgetown \n",
"Belarus Minsk \n",
"Belgium Brussels \n",
"Belize Belmopan \n",
"Benin Porto-Novo (official)Cotonou (de facto) \n",
"Bermuda Hamilton \n",
"Bhutan Thimphu \n",
"Bolivia Sucre (constitutional)La Paz (administrative) \n",
"Bosnia and Herzegovina Sarajevo \n",
"... ... \n",
"Taiwan Taipei \n",
"Tajikistan Dushanbe \n",
"Tanzania Dodoma (official, legislative) \n",
"Thailand Bangkok \n",
"Togo Lomé \n",
"Tonga Nukuʻalofa \n",
"Transnistria Tiraspol \n",
"Trinidad and Tobago Port of Spain \n",
"Tristan da Cunha Edinburgh of the Seven Seas \n",
"Tunisia Tunis \n",
"Turkey Ankara \n",
"Turkmenistan Ashgabat \n",
"Turks and Caicos Islands Cockburn Town \n",
"Tuvalu Funafuti \n",
"Uganda Kampala \n",
"Ukraine Kiev \n",
"United Arab Emirates Abu Dhabi \n",
"United Kingdom London \n",
"United States Washington \n",
"United States Virgin Islands Charlotte Amalie \n",
"Uruguay Montevideo \n",
"Uzbekistan Tashkent \n",
"Vanuatu Port Vila \n",
"Vatican City Vatican City \n",
"Venezuela Caracas \n",
"Vietnam Hanoi \n",
"Wallis and Futuna Mata-Utu \n",
"Yemen Sana'a (de jure) \n",
"Zambia Lusaka \n",
"Zimbabwe Harare \n",
"\n",
" Notes \n",
"Country \n",
"Abkhazia De facto independent state recognised by Russi... \n",
"Afghanistan \n",
"Akrotiri and Dhekelia British Overseas Territory \n",
"Albania \n",
"Algeria \n",
"American Samoa Territory of the United States \n",
"Andorra \n",
"Angola \n",
"Anguilla British Overseas Territory \n",
"Antigua and Barbuda \n",
"Argentina \n",
"Armenia \n",
"Artsakh The self-declared country remains diplomatical... \n",
"Aruba Self-governing country within the Kingdom of t... \n",
"Ascension Island Part of the British Overseas Territory of Sain... \n",
"Australia \n",
"Austria \n",
"Azerbaijan \n",
"Bahamas \n",
"Bahrain \n",
"Bangladesh \n",
"Barbados \n",
"Belarus \n",
"Belgium Also the de facto capital of the European Union \n",
"Belize \n",
"Benin \n",
"Bermuda British Overseas Territory \n",
"Bhutan \n",
"Bolivia La Paz is the highest administrative capital (... \n",
"Bosnia and Herzegovina \n",
"... ... \n",
"Taiwan Officially the Republic of China (ROC), it has... \n",
"Tajikistan \n",
"Tanzania Dar es Salaam, the former capital and largest ... \n",
"Thailand \n",
"Togo \n",
"Tonga \n",
"Transnistria De facto independent state, not recognized by ... \n",
"Trinidad and Tobago \n",
"Tristan da Cunha Part of the British Overseas Territory of Sain... \n",
"Tunisia \n",
"Turkey \n",
"Turkmenistan \n",
"Turks and Caicos Islands British Overseas Territory \n",
"Tuvalu \n",
"Uganda \n",
"Ukraine \n",
"United Arab Emirates \n",
"United Kingdom Prior to the Acts of Union in 1707, London was... \n",
"United States \n",
"United States Virgin Islands Territory of the U.S. \n",
"Uruguay \n",
"Uzbekistan \n",
"Vanuatu \n",
"Vatican City City-state \n",
"Venezuela \n",
"Vietnam \n",
"Wallis and Futuna Overseas collectivity of France \n",
"Yemen Sana'a has been occupied by Houthis rebels sin... \n",
"Zambia \n",
"Zimbabwe \n",
"\n",
"[243 rows x 2 columns]"
]
},
"execution_count": 89,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"def capitals():\n",
" page = \"https://en.wikipedia.org/wiki/List_of_national_capitals\"\n",
" wikitables = pd.read_html(page,\n",
" attrs={\"class\":\"wikitable\"},\n",
" index_col=1,\n",
" header=0,\n",
" keep_default_na = False,\n",
" )\n",
" w = wikitables[0]\n",
" w.sort_index(inplace=True)\n",
" return w\n",
"c = capitals()\n",
"c"
]
},
{
"cell_type": "code",
"execution_count": 88,
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style>\n",
" .dataframe thead tr:only-child th {\n",
" text-align: right;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: left;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Highest point</th>\n",
" <th>Maximum elevation</th>\n",
" <th>Lowest point</th>\n",
" <th>Minimum elevation</th>\n",
" <th>Elevation span</th>\n",
" </tr>\n",
" <tr>\n",
" <th>Country or region</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>Afghanistan</th>\n",
" <td>Noshaq</td>\n",
" <td>7492.0</td>\n",
" <td>Amu Darya</td>\n",
" <td>258.0</td>\n",
" <td>7234.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Albania</th>\n",
" <td>Korab</td>\n",
" <td>2764.0</td>\n",
" <td>Adriatic Sea</td>\n",
" <td>0.0</td>\n",
" <td>2764.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Algeria</th>\n",
" <td>Mount Tahat</td>\n",
" <td>3003.0</td>\n",
" <td>Chott Melrhir</td>\n",
" <td>-40.0</td>\n",
" <td>3043.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>American Samoa</th>\n",
" <td>Lata Mountain on Ta‘ū</td>\n",
" <td>966.0</td>\n",
" <td>South Pacific Ocean</td>\n",
" <td>0.0</td>\n",
" <td>966.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Andorra</th>\n",
" <td>Coma Pedrosa</td>\n",
" <td>2942.0</td>\n",
" <td>Gran Valira</td>\n",
" <td>840.0</td>\n",
" <td>2102.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Angola</th>\n",
" <td>Mount Moco</td>\n",
" <td>2620.0</td>\n",
" <td>South Atlantic Ocean</td>\n",
" <td>0.0</td>\n",
" <td>2620.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Anguilla</th>\n",
" <td>Crocus Hill</td>\n",
" <td>65.0</td>\n",
" <td>Caribbean Sea</td>\n",
" <td>0.0</td>\n",
" <td>65.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Antarctica</th>\n",
" <td>Mount Vinson</td>\n",
" <td>4892.0</td>\n",
" <td>Deep Lake, Vestfold Hills[1][citation needed]</td>\n",
" <td>-50.0</td>\n",
" <td>4942.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Antigua and Barbuda</th>\n",
" <td>Mount Obama on Antigua</td>\n",
" <td>402.0</td>\n",
" <td>Caribbean Sea</td>\n",
" <td>0.0</td>\n",
" <td>402.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Argentina</th>\n",
" <td>Aconcagua[2][3]</td>\n",
" <td>6960.0</td>\n",
" <td>Laguna del Carbón[4]</td>\n",
" <td>-105.0</td>\n",
" <td>7065.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Armenia</th>\n",
" <td>Mount Aragats</td>\n",
" <td>4090.0</td>\n",
" <td>Debed</td>\n",
" <td>400.0</td>\n",
" <td>3690.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Aruba</th>\n",
" <td>Mount Jamanota</td>\n",
" <td>188.0</td>\n",
" <td>Caribbean Sea</td>\n",
" <td>0.0</td>\n",
" <td>188.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Ashmore and Cartier Islands</th>\n",
" <td>unnamed location</td>\n",
" <td>3.0</td>\n",
" <td>Indian Ocean</td>\n",
" <td>0.0</td>\n",
" <td>3.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Australia</th>\n",
" <td>Mount Kosciuszko[5]</td>\n",
" <td>2228.0</td>\n",
" <td>Lake Eyre</td>\n",
" <td>-15.0</td>\n",
" <td>2243.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Austria</th>\n",
" <td>Grossglockner</td>\n",
" <td>3798.0</td>\n",
" <td>Lake Neusiedl</td>\n",
" <td>115.0</td>\n",
" <td>3683.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Azerbaijan</th>\n",
" <td>Mount Bazardüzü</td>\n",
" <td>4485.0</td>\n",
" <td>Caspian Sea</td>\n",
" <td>-28.0</td>\n",
" <td>4513.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Bahamas</th>\n",
" <td>Mount Alvernia on Cat Island</td>\n",
" <td>63.0</td>\n",
" <td>North Atlantic Ocean</td>\n",
" <td>0.0</td>\n",
" <td>63.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Bahrain</th>\n",
" <td>Mountain of Smoke</td>\n",
" <td>122.0</td>\n",
" <td>Persian Gulf</td>\n",
" <td>0.0</td>\n",
" <td>122.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Bangladesh</th>\n",
" <td>Saka Haphong</td>\n",
" <td>1052.0</td>\n",
" <td>Bay of Bengal</td>\n",
" <td>0.0</td>\n",
" <td>1052.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Barbados</th>\n",
" <td>Mount Hillaby</td>\n",
" <td>336.0</td>\n",
" <td>North Atlantic Ocean</td>\n",
" <td>0.0</td>\n",
" <td>336.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Belarus</th>\n",
" <td>Dzyarzhynskaya Hara</td>\n",
" <td>346.0</td>\n",
" <td>Neman</td>\n",
" <td>90.0</td>\n",
" <td>256.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Belgium</th>\n",
" <td>Signal de Botrange</td>\n",
" <td>694.0</td>\n",
" <td>Multiple, west of Veurne 51°02′00″N 2°35′52″E...</td>\n",
" <td>-4.0</td>\n",
" <td>698.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Belize</th>\n",
" <td>Doyle's Delight</td>\n",
" <td>1124.0</td>\n",
" <td>Caribbean Sea</td>\n",
" <td>0.0</td>\n",
" <td>1124.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Benin</th>\n",
" <td>Mont Sokbaro</td>\n",
" <td>658.0</td>\n",
" <td>Bight of Benin</td>\n",
" <td>0.0</td>\n",
" <td>658.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Bermuda</th>\n",
" <td>Town Hill</td>\n",
" <td>76.0</td>\n",
" <td>North Atlantic Ocean</td>\n",
" <td>0.0</td>\n",
" <td>76.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Bhutan</th>\n",
" <td>Gangkhar Puensum</td>\n",
" <td>7570.0</td>\n",
" <td>Drangme Chhu</td>\n",
" <td>97.0</td>\n",
" <td>7473.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Bolivia</th>\n",
" <td>Sajama</td>\n",
" <td>6542.0</td>\n",
" <td>Paraguay River</td>\n",
" <td>90.0</td>\n",
" <td>6452.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Bosnia and Herzegovina</th>\n",
" <td>Maglić</td>\n",
" <td>2386.0</td>\n",
" <td>Adriatic Sea</td>\n",
" <td>0.0</td>\n",
" <td>2386.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Botswana</th>\n",
" <td>Otse Hill</td>\n",
" <td>1491.0</td>\n",
" <td>confluence of Limpopo River and Shashe River</td>\n",
" <td>513.0</td>\n",
" <td>978.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Bouvet Island</th>\n",
" <td>Olavtoppen</td>\n",
" <td>935.0</td>\n",
" <td>South Atlantic Ocean</td>\n",
" <td>0.0</td>\n",
" <td>935.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Tajikistan</th>\n",
" <td>Ismoil Somoni Peak</td>\n",
" <td>7495.0</td>\n",
" <td>Syr Darya</td>\n",
" <td>300.0</td>\n",
" <td>7195.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Tanzania</th>\n",
" <td>Kilimanjaro[57][58]</td>\n",
" <td>5892.0</td>\n",
" <td>Indian Ocean</td>\n",
" <td>0.0</td>\n",
" <td>5892.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Thailand</th>\n",
" <td>Doi Inthanon</td>\n",
" <td>2565.0</td>\n",
" <td>Gulf of ThailandAndaman Sea</td>\n",
" <td>0.0</td>\n",
" <td>2565.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Timor-Leste</th>\n",
" <td>Mount Ramelau on Timor</td>\n",
" <td>2963.0</td>\n",
" <td>Timor Sea</td>\n",
" <td>0.0</td>\n",
" <td>2963.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Togo</th>\n",
" <td>Mont Agou</td>\n",
" <td>986.0</td>\n",
" <td>Bight of Benin</td>\n",
" <td>0.0</td>\n",
" <td>986.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Tokelau</th>\n",
" <td>unnamed location</td>\n",
" <td>5.0</td>\n",
" <td>South Pacific Ocean</td>\n",
" <td>0.0</td>\n",
" <td>5.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Tonga</th>\n",
" <td>unnamed location on Kao</td>\n",
" <td>1033.0</td>\n",
" <td>South Pacific Ocean</td>\n",
" <td>0.0</td>\n",
" <td>1033.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Trinidad and Tobago</th>\n",
" <td>El Cerro del Aripo on Trinidad</td>\n",
" <td>940.0</td>\n",
" <td>Caribbean Sea</td>\n",
" <td>0.0</td>\n",
" <td>940.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Tunisia</th>\n",
" <td>Jebel ech Chambi</td>\n",
" <td>1544.0</td>\n",
" <td>Shatt al Gharsah</td>\n",
" <td>-17.0</td>\n",
" <td>1561.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Turkey</th>\n",
" <td>Mount Ararat</td>\n",
" <td>5137.0</td>\n",
" <td>Mediterranean SeaBlack Sea</td>\n",
" <td>0.0</td>\n",
" <td>5137.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Turkmenistan</th>\n",
" <td>Aýrybaba</td>\n",
" <td>3139.0</td>\n",
" <td>Vpadina Akchanaya[59]</td>\n",
" <td>-81.0</td>\n",
" <td>3220.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Turks and Caicos Islands</th>\n",
" <td>Blue Hills on Providenciales</td>\n",
" <td>49.0</td>\n",
" <td>North Atlantic Ocean</td>\n",
" <td>0.0</td>\n",
" <td>49.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Tuvalu</th>\n",
" <td>unnamed location</td>\n",
" <td>5.0</td>\n",
" <td>South Pacific Ocean</td>\n",
" <td>0.0</td>\n",
" <td>5.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Uganda</th>\n",
" <td>Margherita Peak</td>\n",
" <td>5109.0</td>\n",
" <td>Albert Nile</td>\n",
" <td>621.0</td>\n",
" <td>4488.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Ukraine</th>\n",
" <td>Hoverla</td>\n",
" <td>2061.0</td>\n",
" <td>Kuyalnik Estuary</td>\n",
" <td>-5.0</td>\n",
" <td>2066.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>United Arab Emirates</th>\n",
" <td>Jabal Al Jais</td>\n",
" <td>1910.0</td>\n",
" <td>Persian GulfGulf of Oman</td>\n",
" <td>0.0</td>\n",
" <td>1910.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>United Kingdom</th>\n",
" <td>Ben Nevis</td>\n",
" <td>1345.0</td>\n",
" <td>The Fens</td>\n",
" <td>-4.0</td>\n",
" <td>1349.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>United States</th>\n",
" <td>Denali[60][61][62][63]</td>\n",
" <td>6190.5</td>\n",
" <td>Badwater Basin[64]</td>\n",
" <td>-85.0</td>\n",
" <td>6275.5</td>\n",
" </tr>\n",
" <tr>\n",
" <th>United States Minor Outlying Islands</th>\n",
" <td>unnamed hill on Sand Island</td>\n",
" <td>13.0</td>\n",
" <td>Pacific Ocean</td>\n",
" <td>0.0</td>\n",
" <td>13.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>United States Virgin Islands</th>\n",
" <td>Crown Mountain on Saint Thomas</td>\n",
" <td>474.0</td>\n",
" <td>Caribbean Sea</td>\n",
" <td>0.0</td>\n",
" <td>474.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Uruguay</th>\n",
" <td>Cerro Catedral</td>\n",
" <td>514.0</td>\n",
" <td>South Atlantic Ocean</td>\n",
" <td>0.0</td>\n",
" <td>514.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Uzbekistan</th>\n",
" <td>Khazret Sultan</td>\n",
" <td>4643.0</td>\n",
" <td>Sariqarnish Kuli[59]</td>\n",
" <td>-12.0</td>\n",
" <td>4655.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Vanuatu</th>\n",
" <td>Mount Tabwemasana on Espiritu Santo</td>\n",
" <td>1877.0</td>\n",
" <td>South Pacific Ocean</td>\n",
" <td>0.0</td>\n",
" <td>1877.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Vatican City</th>\n",
" <td>Vatican Hill</td>\n",
" <td>75.0</td>\n",
" <td>Saint Peter's Square</td>\n",
" <td>33.0</td>\n",
" <td>42.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Venezuela</th>\n",
" <td>Pico Bolívar</td>\n",
" <td>4978.0</td>\n",
" <td>Lagunillas Municipality, Zulia</td>\n",
" <td>-12.0</td>\n",
" <td>4990.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Vietnam</th>\n",
" <td>Fan Si Pan</td>\n",
" <td>3143.0</td>\n",
" <td>South China SeaGulf of Thailand</td>\n",
" <td>0.0</td>\n",
" <td>3143.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Wallis and Futuna</th>\n",
" <td>Mont Puke on Futuna</td>\n",
" <td>524.0</td>\n",
" <td>South Pacific Ocean</td>\n",
" <td>0.0</td>\n",
" <td>524.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Yemen</th>\n",
" <td>Jabal an Nabi Shu'ayb</td>\n",
" <td>3666.0</td>\n",
" <td>Arabian Sea</td>\n",
" <td>0.0</td>\n",
" <td>3666.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Zambia</th>\n",
" <td>Mafinga Central</td>\n",
" <td>2329.0</td>\n",
" <td>Zambezi</td>\n",
" <td>329.0</td>\n",
" <td>2000.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Zimbabwe</th>\n",
" <td>Mount Nyangani</td>\n",
" <td>2592.0</td>\n",
" <td>confluence of Runde River and Save River</td>\n",
" <td>162.0</td>\n",
" <td>2430.0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>254 rows × 5 columns</p>\n",
"</div>"
],
"text/plain": [
" Highest point \\\n",
"Country or region \n",
"Afghanistan Noshaq \n",
"Albania Korab \n",
"Algeria Mount Tahat \n",
"American Samoa Lata Mountain on Ta‘ū \n",
"Andorra Coma Pedrosa \n",
"Angola Mount Moco \n",
"Anguilla Crocus Hill \n",
"Antarctica Mount Vinson \n",
"Antigua and Barbuda Mount Obama on Antigua \n",
"Argentina Aconcagua[2][3] \n",
"Armenia Mount Aragats \n",
"Aruba Mount Jamanota \n",
"Ashmore and Cartier Islands unnamed location \n",
"Australia Mount Kosciuszko[5] \n",
"Austria Grossglockner \n",
"Azerbaijan Mount Bazardüzü \n",
"Bahamas Mount Alvernia on Cat Island \n",
"Bahrain Mountain of Smoke \n",
"Bangladesh Saka Haphong \n",
"Barbados Mount Hillaby \n",
"Belarus Dzyarzhynskaya Hara \n",
"Belgium Signal de Botrange \n",
"Belize Doyle's Delight \n",
"Benin Mont Sokbaro \n",
"Bermuda Town Hill \n",
"Bhutan Gangkhar Puensum \n",
"Bolivia Sajama \n",
"Bosnia and Herzegovina Maglić \n",
"Botswana Otse Hill \n",
"Bouvet Island Olavtoppen \n",
"... ... \n",
"Tajikistan Ismoil Somoni Peak \n",
"Tanzania Kilimanjaro[57][58] \n",
"Thailand Doi Inthanon \n",
"Timor-Leste Mount Ramelau on Timor \n",
"Togo Mont Agou \n",
"Tokelau unnamed location \n",
"Tonga unnamed location on Kao \n",
"Trinidad and Tobago El Cerro del Aripo on Trinidad \n",
"Tunisia Jebel ech Chambi \n",
"Turkey Mount Ararat \n",
"Turkmenistan Aýrybaba \n",
"Turks and Caicos Islands Blue Hills on Providenciales \n",
"Tuvalu unnamed location \n",
"Uganda Margherita Peak \n",
"Ukraine Hoverla \n",
"United Arab Emirates Jabal Al Jais \n",
"United Kingdom Ben Nevis \n",
"United States Denali[60][61][62][63] \n",
"United States Minor Outlying Islands unnamed hill on Sand Island \n",
"United States Virgin Islands Crown Mountain on Saint Thomas \n",
"Uruguay Cerro Catedral \n",
"Uzbekistan Khazret Sultan \n",
"Vanuatu Mount Tabwemasana on Espiritu Santo \n",
"Vatican City Vatican Hill \n",
"Venezuela Pico Bolívar \n",
"Vietnam Fan Si Pan \n",
"Wallis and Futuna Mont Puke on Futuna \n",
"Yemen Jabal an Nabi Shu'ayb \n",
"Zambia Mafinga Central \n",
"Zimbabwe Mount Nyangani \n",
"\n",
" Maximum elevation \\\n",
"Country or region \n",
"Afghanistan 7492.0 \n",
"Albania 2764.0 \n",
"Algeria 3003.0 \n",
"American Samoa 966.0 \n",
"Andorra 2942.0 \n",
"Angola 2620.0 \n",
"Anguilla 65.0 \n",
"Antarctica 4892.0 \n",
"Antigua and Barbuda 402.0 \n",
"Argentina 6960.0 \n",
"Armenia 4090.0 \n",
"Aruba 188.0 \n",
"Ashmore and Cartier Islands 3.0 \n",
"Australia 2228.0 \n",
"Austria 3798.0 \n",
"Azerbaijan 4485.0 \n",
"Bahamas 63.0 \n",
"Bahrain 122.0 \n",
"Bangladesh 1052.0 \n",
"Barbados 336.0 \n",
"Belarus 346.0 \n",
"Belgium 694.0 \n",
"Belize 1124.0 \n",
"Benin 658.0 \n",
"Bermuda 76.0 \n",
"Bhutan 7570.0 \n",
"Bolivia 6542.0 \n",
"Bosnia and Herzegovina 2386.0 \n",
"Botswana 1491.0 \n",
"Bouvet Island 935.0 \n",
"... ... \n",
"Tajikistan 7495.0 \n",
"Tanzania 5892.0 \n",
"Thailand 2565.0 \n",
"Timor-Leste 2963.0 \n",
"Togo 986.0 \n",
"Tokelau 5.0 \n",
"Tonga 1033.0 \n",
"Trinidad and Tobago 940.0 \n",
"Tunisia 1544.0 \n",
"Turkey 5137.0 \n",
"Turkmenistan 3139.0 \n",
"Turks and Caicos Islands 49.0 \n",
"Tuvalu 5.0 \n",
"Uganda 5109.0 \n",
"Ukraine 2061.0 \n",
"United Arab Emirates 1910.0 \n",
"United Kingdom 1345.0 \n",
"United States 6190.5 \n",
"United States Minor Outlying Islands 13.0 \n",
"United States Virgin Islands 474.0 \n",
"Uruguay 514.0 \n",
"Uzbekistan 4643.0 \n",
"Vanuatu 1877.0 \n",
"Vatican City 75.0 \n",
"Venezuela 4978.0 \n",
"Vietnam 3143.0 \n",
"Wallis and Futuna 524.0 \n",
"Yemen 3666.0 \n",
"Zambia 2329.0 \n",
"Zimbabwe 2592.0 \n",
"\n",
" Lowest point \\\n",
"Country or region \n",
"Afghanistan Amu Darya \n",
"Albania Adriatic Sea \n",
"Algeria Chott Melrhir \n",
"American Samoa South Pacific Ocean \n",
"Andorra Gran Valira \n",
"Angola South Atlantic Ocean \n",
"Anguilla Caribbean Sea \n",
"Antarctica Deep Lake, Vestfold Hills[1][citation needed] \n",
"Antigua and Barbuda Caribbean Sea \n",
"Argentina Laguna del Carbón[4] \n",
"Armenia Debed \n",
"Aruba Caribbean Sea \n",
"Ashmore and Cartier Islands Indian Ocean \n",
"Australia Lake Eyre \n",
"Austria Lake Neusiedl \n",
"Azerbaijan Caspian Sea \n",
"Bahamas North Atlantic Ocean \n",
"Bahrain Persian Gulf \n",
"Bangladesh Bay of Bengal \n",
"Barbados North Atlantic Ocean \n",
"Belarus Neman \n",
"Belgium Multiple, west of Veurne 51°02′00″N 2°35′52″E... \n",
"Belize Caribbean Sea \n",
"Benin Bight of Benin \n",
"Bermuda North Atlantic Ocean \n",
"Bhutan Drangme Chhu \n",
"Bolivia Paraguay River \n",
"Bosnia and Herzegovina Adriatic Sea \n",
"Botswana confluence of Limpopo River and Shashe River \n",
"Bouvet Island South Atlantic Ocean \n",
"... ... \n",
"Tajikistan Syr Darya \n",
"Tanzania Indian Ocean \n",
"Thailand Gulf of ThailandAndaman Sea \n",
"Timor-Leste Timor Sea \n",
"Togo Bight of Benin \n",
"Tokelau South Pacific Ocean \n",
"Tonga South Pacific Ocean \n",
"Trinidad and Tobago Caribbean Sea \n",
"Tunisia Shatt al Gharsah \n",
"Turkey Mediterranean SeaBlack Sea \n",
"Turkmenistan Vpadina Akchanaya[59] \n",
"Turks and Caicos Islands North Atlantic Ocean \n",
"Tuvalu South Pacific Ocean \n",
"Uganda Albert Nile \n",
"Ukraine Kuyalnik Estuary \n",
"United Arab Emirates Persian GulfGulf of Oman \n",
"United Kingdom The Fens \n",
"United States Badwater Basin[64] \n",
"United States Minor Outlying Islands Pacific Ocean \n",
"United States Virgin Islands Caribbean Sea \n",
"Uruguay South Atlantic Ocean \n",
"Uzbekistan Sariqarnish Kuli[59] \n",
"Vanuatu South Pacific Ocean \n",
"Vatican City Saint Peter's Square \n",
"Venezuela Lagunillas Municipality, Zulia \n",
"Vietnam South China SeaGulf of Thailand \n",
"Wallis and Futuna South Pacific Ocean \n",
"Yemen Arabian Sea \n",
"Zambia Zambezi \n",
"Zimbabwe confluence of Runde River and Save River \n",
"\n",
" Minimum elevation Elevation span \n",
"Country or region \n",
"Afghanistan 258.0 7234.0 \n",
"Albania 0.0 2764.0 \n",
"Algeria -40.0 3043.0 \n",
"American Samoa 0.0 966.0 \n",
"Andorra 840.0 2102.0 \n",
"Angola 0.0 2620.0 \n",
"Anguilla 0.0 65.0 \n",
"Antarctica -50.0 4942.0 \n",
"Antigua and Barbuda 0.0 402.0 \n",
"Argentina -105.0 7065.0 \n",
"Armenia 400.0 3690.0 \n",
"Aruba 0.0 188.0 \n",
"Ashmore and Cartier Islands 0.0 3.0 \n",
"Australia -15.0 2243.0 \n",
"Austria 115.0 3683.0 \n",
"Azerbaijan -28.0 4513.0 \n",
"Bahamas 0.0 63.0 \n",
"Bahrain 0.0 122.0 \n",
"Bangladesh 0.0 1052.0 \n",
"Barbados 0.0 336.0 \n",
"Belarus 90.0 256.0 \n",
"Belgium -4.0 698.0 \n",
"Belize 0.0 1124.0 \n",
"Benin 0.0 658.0 \n",
"Bermuda 0.0 76.0 \n",
"Bhutan 97.0 7473.0 \n",
"Bolivia 90.0 6452.0 \n",
"Bosnia and Herzegovina 0.0 2386.0 \n",
"Botswana 513.0 978.0 \n",
"Bouvet Island 0.0 935.0 \n",
"... ... ... \n",
"Tajikistan 300.0 7195.0 \n",
"Tanzania 0.0 5892.0 \n",
"Thailand 0.0 2565.0 \n",
"Timor-Leste 0.0 2963.0 \n",
"Togo 0.0 986.0 \n",
"Tokelau 0.0 5.0 \n",
"Tonga 0.0 1033.0 \n",
"Trinidad and Tobago 0.0 940.0 \n",
"Tunisia -17.0 1561.0 \n",
"Turkey 0.0 5137.0 \n",
"Turkmenistan -81.0 3220.0 \n",
"Turks and Caicos Islands 0.0 49.0 \n",
"Tuvalu 0.0 5.0 \n",
"Uganda 621.0 4488.0 \n",
"Ukraine -5.0 2066.0 \n",
"United Arab Emirates 0.0 1910.0 \n",
"United Kingdom -4.0 1349.0 \n",
"United States -85.0 6275.5 \n",
"United States Minor Outlying Islands 0.0 13.0 \n",
"United States Virgin Islands 0.0 474.0 \n",
"Uruguay 0.0 514.0 \n",
"Uzbekistan -12.0 4655.0 \n",
"Vanuatu 0.0 1877.0 \n",
"Vatican City 33.0 42.0 \n",
"Venezuela -12.0 4990.0 \n",
"Vietnam 0.0 3143.0 \n",
"Wallis and Futuna 0.0 524.0 \n",
"Yemen 0.0 3666.0 \n",
"Zambia 329.0 2000.0 \n",
"Zimbabwe 162.0 2430.0 \n",
"\n",
"[254 rows x 5 columns]"
]
},
"execution_count": 88,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"def elevation():\n",
" page = \"https://en.wikipedia.org/wiki/List_of_elevation_extremes_by_country\"\n",
" def _conv(s):\n",
" s = unicodedata.normalize('NFKD', s)\n",
" s = s.replace('−','-')\n",
" m = re.search(r'[-+]?([0-9]*\\.[0-9]+|[0-9]+)(?= *m)',s)\n",
" if m:\n",
" return float(m.group(0))\n",
" elif s == 'sea level':\n",
" return 0.0\n",
" else:\n",
" return float('NaN')\n",
" c = {k: _conv for k in ('Maximum elevation', 'Minimum elevation', 'Elevation span')}\n",
" wikitables = pd.read_html(page,\n",
" attrs={\"class\":\"wikitable\"},\n",
" converters = c,\n",
" parse_dates=False,\n",
" encoding='utf-8',\n",
" index_col=0,\n",
" header=0,\n",
" )\n",
" w = wikitables[0]\n",
" w.sort_index(inplace=True)\n",
" return w\n",
"e = elevation()\n",
"e"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style>\n",
" .dataframe thead tr:only-child th {\n",
" text-align: right;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: left;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Rank</th>\n",
" <th>Total</th>\n",
" <th>Land</th>\n",
" <th>Water</th>\n",
" <th>%Water</th>\n",
" <th>Notes</th>\n",
" </tr>\n",
" <tr>\n",
" <th>Sovereign state/dependency</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>Abkhazia</th>\n",
" <td>NaN</td>\n",
" <td>8660.0</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>[Note 48]</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Afghanistan</th>\n",
" <td>40.0</td>\n",
" <td>652230.0</td>\n",
" <td>652230.0</td>\n",
" <td>0.0</td>\n",
" <td>NaN</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Akrotiri and Dhekelia (United Kingdom)</th>\n",
" <td>NaN</td>\n",
" <td>8.0</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>There is a salt lake and some wetlands of unkn...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Albania</th>\n",
" <td>141.0</td>\n",
" <td>28748.0</td>\n",
" <td>27398.0</td>\n",
" <td>1350.0</td>\n",
" <td>7.0</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Algeria</th>\n",
" <td>10.0</td>\n",
" <td>2381741.0</td>\n",
" <td>2381741.0</td>\n",
" <td>0.0</td>\n",
" <td>NaN</td>\n",
" <td>The largest Berber-speaking and Arabic-speakin...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>American Samoa (United States)</th>\n",
" <td>NaN</td>\n",
" <td>199.0</td>\n",
" <td>199.0</td>\n",
" <td>0.0</td>\n",
" <td>NaN</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Andorra</th>\n",
" <td>180.0</td>\n",
" <td>468.0</td>\n",
" <td>468.0</td>\n",
" <td>0.0</td>\n",
" <td>NaN</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Angola</th>\n",
" <td>22.0</td>\n",
" <td>1246700.0</td>\n",
" <td>1246700.0</td>\n",
" <td>0.0</td>\n",
" <td>NaN</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Anguilla (United Kingdom)</th>\n",
" <td>NaN</td>\n",
" <td>91.0</td>\n",
" <td>91.0</td>\n",
" <td>0.0</td>\n",
" <td>NaN</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Antarctica</th>\n",
" <td>NaN</td>\n",
" <td>14000000.0</td>\n",
" <td>14000000.0</td>\n",
" <td>0.0</td>\n",
" <td>NaN</td>\n",
" <td>13,720,000 km2 (5,300,000 sq mi) (98%) of land...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Antigua and Barbuda</th>\n",
" <td>183.0</td>\n",
" <td>442.0</td>\n",
" <td>6.0</td>\n",
" <td>0.0</td>\n",
" <td>NaN</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Argentina</th>\n",
" <td>8.0</td>\n",
" <td>2780400.0</td>\n",
" <td>2736690.0</td>\n",
" <td>43710.0</td>\n",
" <td>57.0</td>\n",
" <td>The largest Spanish-speaking country and secon...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Armenia</th>\n",
" <td>139.0</td>\n",
" <td>29743.0</td>\n",
" <td>28342.0</td>\n",
" <td>1401.0</td>\n",
" <td>71.0</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Artsakh</th>\n",
" <td>NaN</td>\n",
" <td>11458.0</td>\n",
" <td>11458.0</td>\n",
" <td>1200.0</td>\n",
" <td>NaN</td>\n",
" <td>[Note 45] 5.000 km2. Armenian-controlled terri...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Aruba (Netherlands)</th>\n",
" <td>NaN</td>\n",
" <td>180.0</td>\n",
" <td>180.0</td>\n",
" <td>0.0</td>\n",
" <td>NaN</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Ashmore and Cartier Islands (Australia)</th>\n",
" <td>NaN</td>\n",
" <td>5.0</td>\n",
" <td>5.0</td>\n",
" <td>0.0</td>\n",
" <td>NaN</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Australia</th>\n",
" <td>6.0</td>\n",
" <td>7692024.0</td>\n",
" <td>7633565.0</td>\n",
" <td>58459.0</td>\n",
" <td>76.0</td>\n",
" <td>The largest country in Oceania, the largest co...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Austria</th>\n",
" <td>113.0</td>\n",
" <td>83871.0</td>\n",
" <td>82445.0</td>\n",
" <td>1426.0</td>\n",
" <td>7.0</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Azerbaijan</th>\n",
" <td>112.0</td>\n",
" <td>86600.0</td>\n",
" <td>86100.0</td>\n",
" <td>500.0</td>\n",
" <td>13.0</td>\n",
" <td>Largest country in Caucasus.[Note 36]</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Bahamas</th>\n",
" <td>156.0</td>\n",
" <td>13943.0</td>\n",
" <td>10010.0</td>\n",
" <td>3870.0</td>\n",
" <td>88.0</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Bahrain</th>\n",
" <td>174.0</td>\n",
" <td>765.0</td>\n",
" <td>765.0</td>\n",
" <td>0.0</td>\n",
" <td>NaN</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Bangladesh</th>\n",
" <td>92.0</td>\n",
" <td>147570.0</td>\n",
" <td>130168.0</td>\n",
" <td>13830.0</td>\n",
" <td>6.0</td>\n",
" <td>[Note 33]</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Barbados</th>\n",
" <td>184.0</td>\n",
" <td>430.0</td>\n",
" <td>431.0</td>\n",
" <td>0.0</td>\n",
" <td>NaN</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Belarus</th>\n",
" <td>84.0</td>\n",
" <td>207600.0</td>\n",
" <td>202900.0</td>\n",
" <td>4700.0</td>\n",
" <td>26.0</td>\n",
" <td>Largest landlocked country in Europe.</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Belgium</th>\n",
" <td>137.0</td>\n",
" <td>30528.0</td>\n",
" <td>30278.0</td>\n",
" <td>250.0</td>\n",
" <td>82.0</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Belize</th>\n",
" <td>148.0</td>\n",
" <td>22966.0</td>\n",
" <td>22806.0</td>\n",
" <td>160.0</td>\n",
" <td>7.0</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Benin</th>\n",
" <td>100.0</td>\n",
" <td>114763.0</td>\n",
" <td>114305.0</td>\n",
" <td>569.0</td>\n",
" <td>40.0</td>\n",
" <td>[Note 34]</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Bermuda (United Kingdom)</th>\n",
" <td>NaN</td>\n",
" <td>54.0</td>\n",
" <td>54.0</td>\n",
" <td>0.0</td>\n",
" <td>NaN</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Bhutan</th>\n",
" <td>133.0</td>\n",
" <td>38394.0</td>\n",
" <td>38394.0</td>\n",
" <td>0.0</td>\n",
" <td>NaN</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Bir Tawil (Terra nullius)</th>\n",
" <td>NaN</td>\n",
" <td>2060.0</td>\n",
" <td>2060.0</td>\n",
" <td>0.0</td>\n",
" <td>NaN</td>\n",
" <td></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",
" </tr>\n",
" <tr>\n",
" <th>Togo</th>\n",
" <td>123.0</td>\n",
" <td>56785.0</td>\n",
" <td>54385.0</td>\n",
" <td>2400.0</td>\n",
" <td>23.0</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Tokelau (New Zealand)</th>\n",
" <td>NaN</td>\n",
" <td>12.0</td>\n",
" <td>12.0</td>\n",
" <td>0.0</td>\n",
" <td>NaN</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Tonga</th>\n",
" <td>176.0</td>\n",
" <td>747.0</td>\n",
" <td>717.0</td>\n",
" <td>30.0</td>\n",
" <td>2.0</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Transnistria</th>\n",
" <td>NaN</td>\n",
" <td>4163.0</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>[Note 51]</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Trinidad and Tobago</th>\n",
" <td>166.0</td>\n",
" <td>5130.0</td>\n",
" <td>5128.0</td>\n",
" <td>0.0</td>\n",
" <td>NaN</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Tunisia</th>\n",
" <td>91.0</td>\n",
" <td>163610.0</td>\n",
" <td>155360.0</td>\n",
" <td>8250.0</td>\n",
" <td>4.0</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Turkey</th>\n",
" <td>36.0</td>\n",
" <td>783562.0</td>\n",
" <td>769632.0</td>\n",
" <td>13930.0</td>\n",
" <td>78.0</td>\n",
" <td>Transcontinental country located between Asia ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Turkmenistan</th>\n",
" <td>52.0</td>\n",
" <td>488100.0</td>\n",
" <td>469930.0</td>\n",
" <td>18170.0</td>\n",
" <td>72.0</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Turks and Caicos Islands (United Kingdom)</th>\n",
" <td>NaN</td>\n",
" <td>948.0</td>\n",
" <td>430.0</td>\n",
" <td>0.0</td>\n",
" <td>NaN</td>\n",
" <td>[Note 16]</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Tuvalu</th>\n",
" <td>193.0</td>\n",
" <td>26.0</td>\n",
" <td>26.0</td>\n",
" <td>0.0</td>\n",
" <td>NaN</td>\n",
" <td>Smallest Commonwealth realm.</td>\n",
" </tr>\n",
" <tr>\n",
" <th>U.S. Virgin Islands (United States)</th>\n",
" <td>NaN</td>\n",
" <td>347.0</td>\n",
" <td>346.0</td>\n",
" <td>1564.0</td>\n",
" <td>88.0</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Uganda</th>\n",
" <td>79.0</td>\n",
" <td>241550.0</td>\n",
" <td>197100.0</td>\n",
" <td>43938.0</td>\n",
" <td>23.0</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Ukraine</th>\n",
" <td>45.0</td>\n",
" <td>603500.0</td>\n",
" <td>579300.0</td>\n",
" <td>24200.0</td>\n",
" <td>1.0</td>\n",
" <td>Second largest country in Europe and largest c...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>United Arab Emirates</th>\n",
" <td>114.0</td>\n",
" <td>83600.0</td>\n",
" <td>83600.0</td>\n",
" <td>0.0</td>\n",
" <td>NaN</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>United Kingdom</th>\n",
" <td>78.0</td>\n",
" <td>242495.0</td>\n",
" <td>241930.0</td>\n",
" <td>1680.0</td>\n",
" <td>69.0</td>\n",
" <td>Largest island country in Europe and Western H...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>United States</th>\n",
" <td>4.0</td>\n",
" <td>9525067.0</td>\n",
" <td>9147593.0</td>\n",
" <td>377424.0</td>\n",
" <td>96.0</td>\n",
" <td>Largest country in the Western Hemisphere by l...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>United States Minor Outlying Islands</th>\n",
" <td>NaN</td>\n",
" <td>41.0</td>\n",
" <td>2.0</td>\n",
" <td>6937.0</td>\n",
" <td>99.0</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Uruguay</th>\n",
" <td>89.0</td>\n",
" <td>176215.0</td>\n",
" <td>175015.0</td>\n",
" <td>1200.0</td>\n",
" <td>68.0</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Uzbekistan</th>\n",
" <td>56.0</td>\n",
" <td>447400.0</td>\n",
" <td>425400.0</td>\n",
" <td>22000.0</td>\n",
" <td>92.0</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Vanuatu</th>\n",
" <td>158.0</td>\n",
" <td>12189.0</td>\n",
" <td>12189.0</td>\n",
" <td>0.0</td>\n",
" <td>NaN</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Vatican City</th>\n",
" <td>196.0</td>\n",
" <td>44.0</td>\n",
" <td>44.0</td>\n",
" <td>0.0</td>\n",
" <td>NaN</td>\n",
" <td>Smallest country in the world.</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Venezuela</th>\n",
" <td>32.0</td>\n",
" <td>916445.0</td>\n",
" <td>882050.0</td>\n",
" <td>30000.0</td>\n",
" <td>29.0</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Vietnam</th>\n",
" <td>65.0</td>\n",
" <td>331212.0</td>\n",
" <td>310070.0</td>\n",
" <td>21140.0</td>\n",
" <td>38.0</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Wallis and Futuna (France)</th>\n",
" <td>NaN</td>\n",
" <td>142.0</td>\n",
" <td>142.0</td>\n",
" <td>0.0</td>\n",
" <td>NaN</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Western Sahara</th>\n",
" <td>NaN</td>\n",
" <td>266000.0</td>\n",
" <td>266000.0</td>\n",
" <td>0.0</td>\n",
" <td>NaN</td>\n",
" <td>Disputed territory.[Note 29]</td>\n",
" </tr>\n",
" <tr>\n",
" <th>World</th>\n",
" <td>NaN</td>\n",
" <td>510072000.0</td>\n",
" <td>148940000.0</td>\n",
" <td>361132000.0</td>\n",
" <td>8.0</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Yemen</th>\n",
" <td>49.0</td>\n",
" <td>527968.0</td>\n",
" <td>527968.0</td>\n",
" <td>0.0</td>\n",
" <td>NaN</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Zambia</th>\n",
" <td>38.0</td>\n",
" <td>752612.0</td>\n",
" <td>743398.0</td>\n",
" <td>9220.0</td>\n",
" <td>23.0</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Zimbabwe</th>\n",
" <td>60.0</td>\n",
" <td>390757.0</td>\n",
" <td>386847.0</td>\n",
" <td>3910.0</td>\n",
" <td>NaN</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Åland Islands (Finland)</th>\n",
" <td>NaN</td>\n",
" <td>1580.0</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>[Note 56]</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>261 rows × 6 columns</p>\n",
"</div>"
],
"text/plain": [
" Rank Total Land \\\n",
"Sovereign state/dependency \n",
"Abkhazia NaN 8660.0 NaN \n",
"Afghanistan 40.0 652230.0 652230.0 \n",
"Akrotiri and Dhekelia (United Kingdom) NaN 8.0 NaN \n",
"Albania 141.0 28748.0 27398.0 \n",
"Algeria 10.0 2381741.0 2381741.0 \n",
"American Samoa (United States) NaN 199.0 199.0 \n",
"Andorra 180.0 468.0 468.0 \n",
"Angola 22.0 1246700.0 1246700.0 \n",
"Anguilla (United Kingdom) NaN 91.0 91.0 \n",
"Antarctica NaN 14000000.0 14000000.0 \n",
"Antigua and Barbuda 183.0 442.0 6.0 \n",
"Argentina 8.0 2780400.0 2736690.0 \n",
"Armenia 139.0 29743.0 28342.0 \n",
"Artsakh NaN 11458.0 11458.0 \n",
"Aruba (Netherlands) NaN 180.0 180.0 \n",
"Ashmore and Cartier Islands (Australia) NaN 5.0 5.0 \n",
"Australia 6.0 7692024.0 7633565.0 \n",
"Austria 113.0 83871.0 82445.0 \n",
"Azerbaijan 112.0 86600.0 86100.0 \n",
"Bahamas 156.0 13943.0 10010.0 \n",
"Bahrain 174.0 765.0 765.0 \n",
"Bangladesh 92.0 147570.0 130168.0 \n",
"Barbados 184.0 430.0 431.0 \n",
"Belarus 84.0 207600.0 202900.0 \n",
"Belgium 137.0 30528.0 30278.0 \n",
"Belize 148.0 22966.0 22806.0 \n",
"Benin 100.0 114763.0 114305.0 \n",
"Bermuda (United Kingdom) NaN 54.0 54.0 \n",
"Bhutan 133.0 38394.0 38394.0 \n",
"Bir Tawil (Terra nullius) NaN 2060.0 2060.0 \n",
"... ... ... ... \n",
"Togo 123.0 56785.0 54385.0 \n",
"Tokelau (New Zealand) NaN 12.0 12.0 \n",
"Tonga 176.0 747.0 717.0 \n",
"Transnistria NaN 4163.0 NaN \n",
"Trinidad and Tobago 166.0 5130.0 5128.0 \n",
"Tunisia 91.0 163610.0 155360.0 \n",
"Turkey 36.0 783562.0 769632.0 \n",
"Turkmenistan 52.0 488100.0 469930.0 \n",
"Turks and Caicos Islands (United Kingdom) NaN 948.0 430.0 \n",
"Tuvalu 193.0 26.0 26.0 \n",
"U.S. Virgin Islands (United States) NaN 347.0 346.0 \n",
"Uganda 79.0 241550.0 197100.0 \n",
"Ukraine 45.0 603500.0 579300.0 \n",
"United Arab Emirates 114.0 83600.0 83600.0 \n",
"United Kingdom 78.0 242495.0 241930.0 \n",
"United States 4.0 9525067.0 9147593.0 \n",
"United States Minor Outlying Islands NaN 41.0 2.0 \n",
"Uruguay 89.0 176215.0 175015.0 \n",
"Uzbekistan 56.0 447400.0 425400.0 \n",
"Vanuatu 158.0 12189.0 12189.0 \n",
"Vatican City 196.0 44.0 44.0 \n",
"Venezuela 32.0 916445.0 882050.0 \n",
"Vietnam 65.0 331212.0 310070.0 \n",
"Wallis and Futuna (France) NaN 142.0 142.0 \n",
"Western Sahara NaN 266000.0 266000.0 \n",
"World NaN 510072000.0 148940000.0 \n",
"Yemen 49.0 527968.0 527968.0 \n",
"Zambia 38.0 752612.0 743398.0 \n",
"Zimbabwe 60.0 390757.0 386847.0 \n",
"Åland Islands (Finland) NaN 1580.0 NaN \n",
"\n",
" Water %Water \\\n",
"Sovereign state/dependency \n",
"Abkhazia NaN NaN \n",
"Afghanistan 0.0 NaN \n",
"Akrotiri and Dhekelia (United Kingdom) NaN NaN \n",
"Albania 1350.0 7.0 \n",
"Algeria 0.0 NaN \n",
"American Samoa (United States) 0.0 NaN \n",
"Andorra 0.0 NaN \n",
"Angola 0.0 NaN \n",
"Anguilla (United Kingdom) 0.0 NaN \n",
"Antarctica 0.0 NaN \n",
"Antigua and Barbuda 0.0 NaN \n",
"Argentina 43710.0 57.0 \n",
"Armenia 1401.0 71.0 \n",
"Artsakh 1200.0 NaN \n",
"Aruba (Netherlands) 0.0 NaN \n",
"Ashmore and Cartier Islands (Australia) 0.0 NaN \n",
"Australia 58459.0 76.0 \n",
"Austria 1426.0 7.0 \n",
"Azerbaijan 500.0 13.0 \n",
"Bahamas 3870.0 88.0 \n",
"Bahrain 0.0 NaN \n",
"Bangladesh 13830.0 6.0 \n",
"Barbados 0.0 NaN \n",
"Belarus 4700.0 26.0 \n",
"Belgium 250.0 82.0 \n",
"Belize 160.0 7.0 \n",
"Benin 569.0 40.0 \n",
"Bermuda (United Kingdom) 0.0 NaN \n",
"Bhutan 0.0 NaN \n",
"Bir Tawil (Terra nullius) 0.0 NaN \n",
"... ... ... \n",
"Togo 2400.0 23.0 \n",
"Tokelau (New Zealand) 0.0 NaN \n",
"Tonga 30.0 2.0 \n",
"Transnistria NaN NaN \n",
"Trinidad and Tobago 0.0 NaN \n",
"Tunisia 8250.0 4.0 \n",
"Turkey 13930.0 78.0 \n",
"Turkmenistan 18170.0 72.0 \n",
"Turks and Caicos Islands (United Kingdom) 0.0 NaN \n",
"Tuvalu 0.0 NaN \n",
"U.S. Virgin Islands (United States) 1564.0 88.0 \n",
"Uganda 43938.0 23.0 \n",
"Ukraine 24200.0 1.0 \n",
"United Arab Emirates 0.0 NaN \n",
"United Kingdom 1680.0 69.0 \n",
"United States 377424.0 96.0 \n",
"United States Minor Outlying Islands 6937.0 99.0 \n",
"Uruguay 1200.0 68.0 \n",
"Uzbekistan 22000.0 92.0 \n",
"Vanuatu 0.0 NaN \n",
"Vatican City 0.0 NaN \n",
"Venezuela 30000.0 29.0 \n",
"Vietnam 21140.0 38.0 \n",
"Wallis and Futuna (France) 0.0 NaN \n",
"Western Sahara 0.0 NaN \n",
"World 361132000.0 8.0 \n",
"Yemen 0.0 NaN \n",
"Zambia 9220.0 23.0 \n",
"Zimbabwe 3910.0 NaN \n",
"Åland Islands (Finland) NaN NaN \n",
"\n",
" Notes \n",
"Sovereign state/dependency \n",
"Abkhazia [Note 48] \n",
"Afghanistan \n",
"Akrotiri and Dhekelia (United Kingdom) There is a salt lake and some wetlands of unkn... \n",
"Albania \n",
"Algeria The largest Berber-speaking and Arabic-speakin... \n",
"American Samoa (United States) \n",
"Andorra \n",
"Angola \n",
"Anguilla (United Kingdom) \n",
"Antarctica 13,720,000 km2 (5,300,000 sq mi) (98%) of land... \n",
"Antigua and Barbuda \n",
"Argentina The largest Spanish-speaking country and secon... \n",
"Armenia \n",
"Artsakh [Note 45] 5.000 km2. Armenian-controlled terri... \n",
"Aruba (Netherlands) \n",
"Ashmore and Cartier Islands (Australia) \n",
"Australia The largest country in Oceania, the largest co... \n",
"Austria \n",
"Azerbaijan Largest country in Caucasus.[Note 36] \n",
"Bahamas \n",
"Bahrain \n",
"Bangladesh [Note 33] \n",
"Barbados \n",
"Belarus Largest landlocked country in Europe. \n",
"Belgium \n",
"Belize \n",
"Benin [Note 34] \n",
"Bermuda (United Kingdom) \n",
"Bhutan \n",
"Bir Tawil (Terra nullius) \n",
"... ... \n",
"Togo \n",
"Tokelau (New Zealand) \n",
"Tonga \n",
"Transnistria [Note 51] \n",
"Trinidad and Tobago \n",
"Tunisia \n",
"Turkey Transcontinental country located between Asia ... \n",
"Turkmenistan \n",
"Turks and Caicos Islands (United Kingdom) [Note 16] \n",
"Tuvalu Smallest Commonwealth realm. \n",
"U.S. Virgin Islands (United States) \n",
"Uganda \n",
"Ukraine Second largest country in Europe and largest c... \n",
"United Arab Emirates \n",
"United Kingdom Largest island country in Europe and Western H... \n",
"United States Largest country in the Western Hemisphere by l... \n",
"United States Minor Outlying Islands \n",
"Uruguay \n",
"Uzbekistan \n",
"Vanuatu \n",
"Vatican City Smallest country in the world. \n",
"Venezuela \n",
"Vietnam \n",
"Wallis and Futuna (France) \n",
"Western Sahara Disputed territory.[Note 29] \n",
"World \n",
"Yemen \n",
"Zambia \n",
"Zimbabwe \n",
"Åland Islands (Finland) [Note 56] \n",
"\n",
"[261 rows x 6 columns]"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"def area():\n",
" page = \"https://en.wikipedia.org/wiki/List_of_countries_and_dependencies_by_area\"\n",
" def _conv(s):\n",
" s = unicodedata.normalize('NFKD', s)\n",
" m = re.search(r'[0-9]{1,3}(,[0-9]{3})*(?=[(])',s)\n",
" if m:\n",
" return float(m.group(0).replace(',',''))\n",
" else:\n",
" return float('NaN')\n",
" def _conv2(s):\n",
" s = unicodedata.normalize('NFKD', s)\n",
" m = re.search(r'\\d+[^0-9](\\d+)',s)\n",
" if m:\n",
" return float(m.group(1))\n",
" else:\n",
" return float('NaN')\n",
" c = {k: _conv for k in ('Total in km2 (mi2)', 'Land in km2 (mi2)', 'Water in km2 (mi2)')}\n",
" c['Rank'] = _conv2\n",
" c['% water'] = _conv2\n",
" h = [\"len (km)\", \"len (mi)\",\"#borders\", \"#neighbours\", \"neighbours\"]\n",
" wikitables = pd.read_html(page,\n",
" attrs={\"class\":\"wikitable\"},\n",
" converters = c,\n",
" parse_dates=False,\n",
" keep_default_na = False,\n",
" index_col=1,\n",
" header=0,\n",
" )\n",
" w = wikitables[0]\n",
" w.sort_index(inplace=True)\n",
" w.columns = 'Rank Total Land Water %Water Notes'.split(' ')\n",
" return w\n",
"a = area()\n",
"a"
]
},
{
"cell_type": "code",
"execution_count": 47,
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style>\n",
" .dataframe thead tr:only-child th {\n",
" text-align: right;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: left;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Official Language</th>\n",
" <th>Minority Language</th>\n",
" </tr>\n",
" <tr>\n",
" <th>Country</th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>Afghanistan</th>\n",
" <td>Nationwide: Pashto Dari Regional:[2] Uzbek Tur...</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Albania</th>\n",
" <td>Albanian</td>\n",
" <td>Greek (nationwide; official[citation needed] i...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Algeria</th>\n",
" <td>Arabic Tamazight</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Andorra</th>\n",
" <td>Catalan[5]</td>\n",
" <td>Spanish French Portuguese</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Angola</th>\n",
" <td>Portuguese</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Antigua and Barbuda</th>\n",
" <td>English (de facto official) [7]</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Argentina</th>\n",
" <td>Spanish (de facto; de jure in Corrientes and C...</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Armenia</th>\n",
" <td></td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Australia</th>\n",
" <td>English (de facto official)</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Austria</th>\n",
" <td>German Croatian (co-official in several areas ...</td>\n",
" <td>Slovene (statewide) Czech (statewide) Hungaria...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Azerbaijan</th>\n",
" <td></td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Bahamas</th>\n",
" <td>English</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Bahrain</th>\n",
" <td>Arabic</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Bangladesh</th>\n",
" <td></td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Barbados</th>\n",
" <td>English</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Belarus</th>\n",
" <td>Belarusian Russian</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Belgium</th>\n",
" <td>(Languages of Belgium) [14] Dutch (in Flanders...</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Belize</th>\n",
" <td>English</td>\n",
" <td>Spanish (border with Mexico and Guatemala)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Benin</th>\n",
" <td>French</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Bhutan</th>\n",
" <td>Dzongkha</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Bolivia</th>\n",
" <td>Castilian Araona Aymara Baure Bésiro Canichana...</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Bosnia and Herzegovina</th>\n",
" <td>Bosnian Croatian Serbian (all de facto) [16]</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Botswana</th>\n",
" <td>English</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Brazil</th>\n",
" <td>German (in Pomerode [17]) East Pomeranian (in ...</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Brunei</th>\n",
" <td>Malay English</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Bulgaria</th>\n",
" <td>Bulgarian</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Burkina Faso</th>\n",
" <td>French</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Burundi</th>\n",
" <td>Kirundi French English</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Cambodia</th>\n",
" <td>Khmer</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Cameroon</th>\n",
" <td>English French</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Swaziland</th>\n",
" <td>English Swazi</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Sweden</th>\n",
" <td>Swedish</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Switzerland</th>\n",
" <td>German (Aargau, Appenzell Ausserrhoden, Appenz...</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Syria</th>\n",
" <td>Arabic</td>\n",
" <td>Kurdish</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Taiwan</th>\n",
" <td>Hakka Standard Chinese (de facto but not de jure)</td>\n",
" <td>Taiwanese Hokkien Hakka</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Tajikistan</th>\n",
" <td></td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Tanzania</th>\n",
" <td>English</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Thailand</th>\n",
" <td>Thai</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Togo</th>\n",
" <td>French</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Tonga</th>\n",
" <td>English</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Transnistria</th>\n",
" <td>Moldovan Russian Ukrainian</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Trinidad and Tobago</th>\n",
" <td>English</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Tunisia</th>\n",
" <td></td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Turkey</th>\n",
" <td>Turkish</td>\n",
" <td>Kurdish</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Turkmenistan</th>\n",
" <td></td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Tuvalu</th>\n",
" <td>English (de facto)</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Uganda</th>\n",
" <td>English Swahili[53]</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Ukraine</th>\n",
" <td>Ukrainian</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>United Arab Emirates</th>\n",
" <td>Arabic</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>United Kingdom</th>\n",
" <td>English (de facto but not de jure) Cornish (in...</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>United States</th>\n",
" <td>(Languages of the United States and English-on...</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Uruguay</th>\n",
" <td>Spanish (de facto)</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Uzbekistan</th>\n",
" <td></td>\n",
" <td>Uzbek Karakalpak and Uzbek in Karakalpakstan</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Vanuatu</th>\n",
" <td>English French</td>\n",
" <td>Bislama</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Vatican City</th>\n",
" <td>Italian</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Venezuela</th>\n",
" <td>Spanish[55]</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Vietnam</th>\n",
" <td></td>\n",
" <td>Vietnamese</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Yemen</th>\n",
" <td>Arabic</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Zambia</th>\n",
" <td>English</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>Zimbabwe</th>\n",
" <td>Chewa Chibarwe English Kalanga Khoisan[56][57]...</td>\n",
" <td></td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>205 rows × 2 columns</p>\n",
"</div>"
],
"text/plain": [
" Official Language \\\n",
"Country \n",
"Afghanistan Nationwide: Pashto Dari Regional:[2] Uzbek Tur... \n",
"Albania Albanian \n",
"Algeria Arabic Tamazight \n",
"Andorra Catalan[5] \n",
"Angola Portuguese \n",
"Antigua and Barbuda English (de facto official) [7] \n",
"Argentina Spanish (de facto; de jure in Corrientes and C... \n",
"Armenia \n",
"Australia English (de facto official) \n",
"Austria German Croatian (co-official in several areas ... \n",
"Azerbaijan \n",
"Bahamas English \n",
"Bahrain Arabic \n",
"Bangladesh \n",
"Barbados English \n",
"Belarus Belarusian Russian \n",
"Belgium (Languages of Belgium) [14] Dutch (in Flanders... \n",
"Belize English \n",
"Benin French \n",
"Bhutan Dzongkha \n",
"Bolivia Castilian Araona Aymara Baure Bésiro Canichana... \n",
"Bosnia and Herzegovina Bosnian Croatian Serbian (all de facto) [16] \n",
"Botswana English \n",
"Brazil German (in Pomerode [17]) East Pomeranian (in ... \n",
"Brunei Malay English \n",
"Bulgaria Bulgarian \n",
"Burkina Faso French \n",
"Burundi Kirundi French English \n",
"Cambodia Khmer \n",
"Cameroon English French \n",
"... ... \n",
"Swaziland English Swazi \n",
"Sweden Swedish \n",
"Switzerland German (Aargau, Appenzell Ausserrhoden, Appenz... \n",
"Syria Arabic \n",
"Taiwan Hakka Standard Chinese (de facto but not de jure) \n",
"Tajikistan \n",
"Tanzania English \n",
"Thailand Thai \n",
"Togo French \n",
"Tonga English \n",
"Transnistria Moldovan Russian Ukrainian \n",
"Trinidad and Tobago English \n",
"Tunisia \n",
"Turkey Turkish \n",
"Turkmenistan \n",
"Tuvalu English (de facto) \n",
"Uganda English Swahili[53] \n",
"Ukraine Ukrainian \n",
"United Arab Emirates Arabic \n",
"United Kingdom English (de facto but not de jure) Cornish (in... \n",
"United States (Languages of the United States and English-on... \n",
"Uruguay Spanish (de facto) \n",
"Uzbekistan \n",
"Vanuatu English French \n",
"Vatican City Italian \n",
"Venezuela Spanish[55] \n",
"Vietnam \n",
"Yemen Arabic \n",
"Zambia English \n",
"Zimbabwe Chewa Chibarwe English Kalanga Khoisan[56][57]... \n",
"\n",
" Minority Language \n",
"Country \n",
"Afghanistan \n",
"Albania Greek (nationwide; official[citation needed] i... \n",
"Algeria \n",
"Andorra Spanish French Portuguese \n",
"Angola \n",
"Antigua and Barbuda \n",
"Argentina \n",
"Armenia \n",
"Australia \n",
"Austria Slovene (statewide) Czech (statewide) Hungaria... \n",
"Azerbaijan \n",
"Bahamas \n",
"Bahrain \n",
"Bangladesh \n",
"Barbados \n",
"Belarus \n",
"Belgium \n",
"Belize Spanish (border with Mexico and Guatemala) \n",
"Benin \n",
"Bhutan \n",
"Bolivia \n",
"Bosnia and Herzegovina \n",
"Botswana \n",
"Brazil \n",
"Brunei \n",
"Bulgaria \n",
"Burkina Faso \n",
"Burundi \n",
"Cambodia \n",
"Cameroon \n",
"... ... \n",
"Swaziland \n",
"Sweden \n",
"Switzerland \n",
"Syria Kurdish \n",
"Taiwan Taiwanese Hokkien Hakka \n",
"Tajikistan \n",
"Tanzania \n",
"Thailand \n",
"Togo \n",
"Tonga \n",
"Transnistria \n",
"Trinidad and Tobago \n",
"Tunisia \n",
"Turkey Kurdish \n",
"Turkmenistan \n",
"Tuvalu \n",
"Uganda \n",
"Ukraine \n",
"United Arab Emirates \n",
"United Kingdom \n",
"United States \n",
"Uruguay \n",
"Uzbekistan Uzbek Karakalpak and Uzbek in Karakalpakstan \n",
"Vanuatu Bislama \n",
"Vatican City \n",
"Venezuela \n",
"Vietnam Vietnamese \n",
"Yemen \n",
"Zambia \n",
"Zimbabwe \n",
"\n",
"[205 rows x 2 columns]"
]
},
"execution_count": 47,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"def language():\n",
" page = 'https://en.wikipedia.org/wiki/List_of_official_languages_by_country_and_territory'\n",
" def _conv(s):\n",
" s = unicodedata.normalize('NFKD', s)\n",
" if '[edit]' in s or 'Country' in s:\n",
" return float('NaN')\n",
" return re.sub(r'\\[[0-9]+\\]','',s)\n",
" c = {'Country': _conv}\n",
" wikitables = pd.read_html(page,\n",
" attrs={\"class\":\"wikitable\"},\n",
" converters = c,\n",
" #index_col=0,\n",
" skiprows=(0,),\n",
" parse_dates=False,\n",
" keep_default_na = False,\n",
" header=0,\n",
" )\n",
" w = wikitables[0]\n",
" w.dropna(subset=['Country'], inplace=True)\n",
" w.set_index('Country', inplace=True)\n",
" w.drop(labels=['Unnamed: 5', 'National Language', 'Widely Spoken'], axis=1, inplace=True)\n",
" w.sort_index(inplace=True)\n",
" return w\n",
"l = language()\n",
"l\n",
"\n",
"# THIS IS ALL FUCKED. THE WIKITABLE IS THE WORST!"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.5.2"
},
"varInspector": {
"cols": {
"lenName": 16,
"lenType": 16,
"lenVar": "120"
},
"kernels_config": {
"python": {
"delete_cmd_postfix": "",
"delete_cmd_prefix": "del ",
"library": "var_list.py",
"varRefreshCmd": "print(var_dic_list())"
},
"r": {
"delete_cmd_postfix": ") ",
"delete_cmd_prefix": "rm(",
"library": "var_list.r",
"varRefreshCmd": "cat(var_dic_list()) "
}
},
"types_to_exclude": [
"module",
"function",
"builtin_function_or_method",
"instance",
"_Feature"
],
"window_display": false
}
},
"nbformat": 4,
"nbformat_minor": 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment