bblocks.import_tools.debt.get_data

Helper functions to generate the URL and extract the data from the IDS database.

Functions

_time_period(→ str)

Take a period range and convert it to an API compatible string

_country_list(→ str)

Take a country list and convert it to an API compatible string

_api_url(→ str)

Query string for API for IDS data. One indicator at a time

_clean_ids_response(→ pandas.DataFrame)

get_indicator_data(→ pandas.DataFrame)

Get data for a single indicator from the World Bank API

Module Contents

bblocks.import_tools.debt.get_data._time_period(start_year: int, end_year: int) str

Take a period range and convert it to an API compatible string

bblocks.import_tools.debt.get_data._country_list(countries: str | list) str

Take a country list and convert it to an API compatible string

bblocks.import_tools.debt.get_data._api_url(indicator: str, countries: str | list, start_year: int, end_year: int, source: int) str

Query string for API for IDS data. One indicator at a time

bblocks.import_tools.debt.get_data._clean_ids_response(data: pandas.DataFrame, indicator: str) pandas.DataFrame
bblocks.import_tools.debt.get_data.get_indicator_data(indicator: str, countries: str | list = 'all', start_year: int = 2017, end_year: int = 2025, source: int = 6, try_again: bool = True) pandas.DataFrame

Get data for a single indicator from the World Bank API

Parameters:
  • indicator – The indicator to get data for

  • countries – The countries to get data for. Defaults to all countries

  • start_year – The start year for the data. Defaults to 2017

  • end_year – The end year for the data. Defaults to 2025

  • source – The source of the data. Defaults to 6 (IDS)

  • try_again – Whether to try again if the API fails. Defaults to True

Returns:

A dataframe with the data