Create a new Google Colab notebook
The following steps will serve as a guideline to find all pairs from five selected countries:
Create a new notebook using the Google Colab environment.
Read data and create a data frame using the table with the names of the available countries from the WITS site:
https://wits.worldbank.org/wits/wits/witshelp/content/codes/country_codes.htm
The information from the previous site could be transformed into a table format (pandas data frame format) with the following command read_html: 'https://wits.worldbank.org/wits/wits/witshelp/content/codes/country_codes.htm'.
Since the variable list_WITS is a list with several data, to select the right data table use the command list_WITS[0]:
import pandas as pd
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
list_WITS = pd.read_html('https://wits.worldbank.org/wits/wits/witshelp/content/codes/country_codes.htm', header=[1])
table_WITS = list_WITS[0]
4. Select the information from the column 'Country Name':
table_WITS['Country Name']
0 Afghanistan
1 Albania
2 Algeria
3 American Samoa
4 Andorra
...
259 Yemen, Rep.
260 Yugoslavia
261 Yugoslavia, FR (Serbia/Montene
262 Zambia
263 Zimbabwe
Name: Country Name, Length: 264, dtype: object
5. Convert the column with the names of the countries into a list using the command list:
country_name_list = list(table_WITS['Country Name'])
['Afghanistan', 'Albania', 'Algeria', 'American Samoa', 'Andorra', 'Angola', ... 'Yugoslavia, FR (Serbia/Montene', 'Zambia', 'Zimbabwe']
6. After creating a list, extract the name of the five selected countries using the operator [0:5] to access just the five first elements in a list:
country_name_list[0:5]
['Afghanistan', 'Albania', 'Algeria', 'American Samoa', 'Andorra']
7. The Python code with all the steps is summarized in this Google Colab (click on the link):
https://colab.research.google.com/drive/1-2AUAiSZ1TqRFAomTGDU3WP0MIaookXy?usp=sharing