bblocks.import_tools.debt.wb_ids ================================ .. py:module:: bblocks.import_tools.debt.wb_ids .. autoapi-nested-parse:: Import data from the World Bank's International Debt Statistics database Classes ------- .. autoapisummary:: bblocks.import_tools.debt.wb_ids.DebtIDS Functions --------- .. autoapisummary:: bblocks.import_tools.debt.wb_ids.read_indicators Module Contents --------------- .. py:function:: read_indicators(file: str = 'ids') -> dict Read a json which contains the IDS indicators stored in the requested file :param file: The file to read - either 'ids','debt_stocks', or 'debt_service'. Defaults to "ids" :type file: str .. py:class:: DebtIDS Bases: :py:obj:`bblocks.import_tools.common.ImportData` Import data from the World Bank's International Debt Statistics database. To use this object, first create an instance of it. Then use the `load_data` method to load indicators. One or more indicators can be loaded at a time, and a starting and end year must be specified. If the data has not been downloaded before, it will be downloaded from the World Bank API. If the data has been downloaded before, it will be loaded from the local data folder. To get a DataFrame, use the `get_data` method. You can get the data for one or more, or for all indicators at once. To update the data, use the `update_data` method. This will download the latest data from the World Bank API and overwrite the local data. - To get a list of available indicators, use the `get_available_indicators` method. - To get a list of available debt service indicators, use the `debt_service_indicators` method. - To get a list of available debt stocks indicators, use the `debt_stocks_indicators` method. .. py:method:: __post_init__() Set the path to the data folder and create it if it doesn't exist .. py:method:: _check_stored_data(indicator: str, start_year: int, end_year: int) -> str | bool Check if the data is already stored locally This also checks if the years requested are inside another file. :param indicator: The indicator to check :type indicator: str :param start_year: The start year of the data :type start_year: int :param end_year: The end year of the data :type end_year: int :returns: The filename of the data if it exists bool: False if the data doesn't exist :rtype: str .. py:method:: _indicator_parameters(indicator: str) -> tuple[str, int, int] :staticmethod: Get the indicator, start year and end year from the indicator name. .. py:method:: get_available_indicators() -> dict :classmethod: Get a dictionary of all available indicators in the IDS database. .. py:method:: debt_service_indicators(detailed_category: bool = True) -> dict :classmethod: Get a dictionary of Debt Service indicators in the IDS database. .. py:method:: debt_stocks_indicators(detailed_category: bool = True) -> dict :classmethod: Get a dictionary of Debt Service indicators in the IDS database. .. py:method:: _get_indicator(indicator: str, start_year: int, end_year: int) -> bblocks.import_tools.common.ImportData Get data for an indicator. This method is not meant to be accessed directly. Instead, use the `.get_data()` method. :param indicator: The indicator to get. They must be in the IDS format (e.g. DT.DOD.DECT.CD). To view all available indicators, call `.get_available_indicators()`. :returns: The same object to allow chaining of methods .. py:method:: load_data(indicators: str | list, start_year: int, end_year: int) -> bblocks.import_tools.common.ImportData Load the data for an indicator or a list of indicators. :param indicators: The indicator(s) to load. They must be in the IDS format (e.g. DT.DOD.DECT.CD). To view all available indicators, call `.get_available_indicators()`. :param start_year: The first year to include in the data :param end_year: The last year to include in the data .. py:method:: update_data(reload_data: bool = True) -> bblocks.import_tools.common.ImportData Update the data for all loaded indicators. .. py:method:: get_data(indicators: str | list = 'all', **kwargs) -> pandas.DataFrame Get the data for an indicator or a list of indicators. :param indicators: The indicator(s) to get. They must be in the IDS format (e.g. DT.DOD.DECT.CD). To get all available indicators, set `indicators="all"`. :returns: A pandas dataframe with the requested data.