wbwdi
is a Polars-based Python library to access and analyze the World Bank’s World Development Indicators (WDI) using the corresponding API. WDI provides more than 24,000 country or region-level indicators for various contexts. wbwdi
enables users to download, process and work with WDI series across multiple entities and time periods.
This library is a product of Christoph Scheuch and not sponsored by or affiliated with the World Bank in any way. For an R implementation, please consider the r-wbwdi
package. For packages with a shared design philosophy, check out the econdataverse.
You can install the release version from PyPI:
pip install wbwdi
You can install the development version from GitHub:
pip install "git+https://github.com/tidy-intelligence/py-wbwdi"
The main function wdi_get()
provides an interface to download multiple WDI series for multiple entities and specific date ranges.
from wbwdi import wdi_get
wdi_get(
entities = ["MEX", "CAN", "USA"],
indicators = ["NY.GDP.PCAP.KD", "SP.POP.TOTL"],
start_year = 2020, end_year = 2024
)
You can also download these indicators for all entities and available dates:
wdi_get(
entities = "all",
indicators = ["NY.GDP.PCAP.KD", "SP.POP.TOTL"]
)
Some indicators are also available on a monthly basis, e.g.:
wdi_get(
entities = "AUT",
indicators = "DPANUSSPB",
start_year = 2012, end_year = 2015,
frequency = "month"
)
Similarly, there are also some indicators available on a quarterly frequency, e.g.:
wdi_get(
entities = "NGA",
indicators = "DT.DOD.DECT.CD.TL.US",
start_year = 2012, end_year = 2015,
frequency = "quarter"
)
You can get a list of all indicators supported by the WDI API via:
from wbwdi import wdi_get_indicators
wdi_get_indicators()
You can get a list of all supported entities via:
from wbwdi import wdi_get_entities
wdi_get_entities()
You can also get the list of supported indicators and entities in another language, but note that not everything seems to be translated into other languages:
wdi_get_indicators(language = "es")
wdi_get_entities(language = "zh")
Check out the following function for a list of supported languages:
from wbwdi import wdi_get_languages
wdi_get_languages()
In addition, you can list supported regions, sources, topics and lending types, respectively:
from wbwdi import wdi_get_regions, wdi_get_sources, wdi_get_topics, wdi_get_lending_types
wdi_get_regions()
wdi_get_sources()
wdi_get_topics()
wdi_get_lending_types()
If you want to search for specific keywords among indicators or other data sources, you can use the Positron data explorer. Alternatively, this package comes with a helper function:
from wbwdi import wdi_get_indicators, wdi_search
indicators = wdi_get_indicators()
wdi_search(
indicators,
keywords = ["inequality", "gender"],
columns = ["indicator_name"]
)
There are already great libraries that allow you to interact with the World Bank WDI API. The two main reasons why this library exists are: (i) to have an implementation based on Polars rather than pandas, and (ii) to have an interface consistent with the econdataverse.