def read_worldbank(iso3166alpha3):
    ' Fetches and tidies all ~1500 World Bank indicators\n        for a given ISO 3166 alpha 3 code.\n\n        For a particular alpha 3 code, this function fetches the entire ZIP\n        file for that particular country for all World Bank indicators in a\n        wide format where years are columns. The dataframe is changed into a\n        narrow format so that year becomes a single column with each row\n        representing a different year for a single indicator.\n\n        Args:\n            iso3166alpha3: ISO 3166 alpha 3 for a country, as a string.\n\n        Returns:\n            A tidied pandas dataframe with all indicator codes for a particular\n            country in the format of (country, indicator, year, value).\n\n        Notes:\n            Takes approximately 10 seconds to download and\n            tidy one country in a Jupyter notebook.\n    '
    country_zip = (('http://api.worldbank.org/v2/en/country/' + iso3166alpha3) + '?downloadformat=csv')
    r = requests.get(country_zip)
    filebytes = io.BytesIO(r.content)
    myzipfile = zipfile.ZipFile(filebytes)
    file_to_open = None
    for file in myzipfile.namelist():
        if file.startswith('API'):
            file_to_open = file
            break
    assert (file_to_open is not None), ('Failed to find data for' + iso3166alpha3)
    df = None
    line_match = re.compile('\\"([^\\"]*)\\"')
    for line in myzipfile.open(file_to_open).readlines():
        cols = line_match.findall(line.decode('utf-8'))
        if (len(cols) > 2):
            if (df is None):
                df = pd.DataFrame(columns=cols)
            else:
                df = df.append(pd.DataFrame([cols], columns=df.columns), ignore_index=True)
    df = df.rename(columns=WORLDBANK_COL_REMAP)
    df = df.set_index(['CountryName', 'CountryCode', 'IndicatorName', 'IndicatorCode'])
    df = df.stack()
    df.index = df.index.rename('year', level=4)
    df.name = 'Value'
    df = df.reset_index()
    df['Value'] = pd.to_numeric(df['Value'])
    df = df.dropna()
    return df
Fetches and tidies all ~1500 World Bank indicators
for a given ISO 3166 alpha 3 code.

For a particular alpha 3 code, this function fetches the entire ZIP
file for that particular country for all World Bank indicators in a
wide format where years are columns. The dataframe is changed into a
narrow format so that year becomes a single column with each row
representing a different year for a single indicator.

Args:
    iso3166alpha3: ISO 3166 alpha 3 for a country, as a string.

Returns:
    A tidied pandas dataframe with all indicator codes for a particular
    country in the format of (country, indicator, year, value).

Notes:
    Takes approximately 10 seconds to download and
    tidy one country in a Jupyter notebook.
def read_worldbank(iso3166alpha3):
    ' Fetches and tidies all ~1500 World Bank indicators\n        for a given ISO 3166 alpha 3 code.\n\n        For a particular alpha 3 code, this function fetches the entire ZIP\n        file for that particular country for all World Bank indicators in a\n        wide format where years are columns. The dataframe is changed into a\n        narrow format so that year becomes a single column with each row\n        representing a different year for a single indicator.\n\n        Args:\n            iso3166alpha3: ISO 3166 alpha 3 for a country, as a string.\n\n        Returns:\n            A tidied pandas dataframe with all indicator codes for a particular\n            country in the format of (country, indicator, year, value).\n\n        Notes:\n            Takes approximately 10 seconds to download and\n            tidy one country in a Jupyter notebook.\n    '
    country_zip = (('http://api.worldbank.org/v2/en/country/' + iso3166alpha3) + '?downloadformat=csv')
    r = requests.get(country_zip)
    filebytes = io.BytesIO(r.content)
    myzipfile = zipfile.ZipFile(filebytes)
    file_to_open = None
    for file in myzipfile.namelist():
        if file.startswith('API'):
            file_to_open = file
            break
    assert (file_to_open is not None), ('Failed to find data for' + iso3166alpha3)
    df = None
    line_match = re.compile('\\"([^\\"]*)\\"')
    for line in myzipfile.open(file_to_open).readlines():
        cols = line_match.findall(line.decode('utf-8'))
        if (len(cols) > 2):
            if (df is None):
                df = pd.DataFrame(columns=cols)
            else:
                df = df.append(pd.DataFrame([cols], columns=df.columns), ignore_index=True)
    df = df.rename(columns=WORLDBANK_COL_REMAP)
    df = df.set_index(['CountryName', 'CountryCode', 'IndicatorName', 'IndicatorCode'])
    df = df.stack()
    df.index = df.index.rename('year', level=4)
    df.name = 'Value'
    df = df.reset_index()
    df['Value'] = pd.to_numeric(df['Value'])
    df = df.dropna()
    return df