Seamless Access to World Bank World Development Indicators with Polars
Project description
py-wbwdi
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.
Installation
You can install the release version from PyPI:
pip install wbwdi
If you want to use the package with pandas, then install with the corresponding dependencies:
pip install wbwdi[pandas]
You also need to set the configuration to pandas (see below).
You can install the development version from GitHub:
pip install "git+https://github.com/tidy-intelligence/py-wbwdi"
Usage
The main function wdi_get() provides an interface to download multiple WDI series for multiple entities and specific date ranges.
import wbwdi as wb
wb.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:
wb.wdi_get(
entities="all",
indicators=["NY.GDP.PCAP.KD", "SP.POP.TOTL"]
)
Some indicators are also available on a monthly basis, e.g.:
wb.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.:
wb.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:
wb.wdi_get_indicators()
You can get a list of all supported entities via:
wb.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:
wb.wdi_get_indicators(language="es")
wb.wdi_get_entities(language="zh")
Check out the following function for a list of supported languages:
wb.wdi_get_languages()
In addition, you can list supported regions, sources, topics and lending types, respectively:
wb.wdi_get_regions()
wb.wdi_get_sources()
wb.wdi_get_topics()
wb.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:
indicators=wb.wdi_get_indicators()
wb.wdi_search(
indicators,
keywords=["inequality", "gender"],
columns=["indicator_name"]
)
If you want to data as a pandas or arrow data frame instead of polars, you can change the corresponding configuration:
wb.wdi_set_format("pandas")
wb.wdi_get(
entities=["MEX", "CAN", "USA"],
indicators=["NY.GDP.PCAP.KD", "SP.POP.TOTL"],
start_year=2020,
end_year=2024
)
Relation to Existing Python Libraries
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wbwdi-1.0.1.tar.gz.
File metadata
- Download URL: wbwdi-1.0.1.tar.gz
- Upload date:
- Size: 30.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.26
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
268b819d9e3d56cb9a91708098d77cd0c8c10ce168570246a660adee244e606c
|
|
| MD5 |
874bd64ca3057d5b2c2e80502960b44f
|
|
| BLAKE2b-256 |
a80b0de798c0e45f0ffa86f547cb173ec5016a66b84027b37f884e7790dbb6ac
|
File details
Details for the file wbwdi-1.0.1-py3-none-any.whl.
File metadata
- Download URL: wbwdi-1.0.1-py3-none-any.whl
- Upload date:
- Size: 18.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.26
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81b710bbf4d3bafa893c0ab645eb10b7832686478377f2869f0fc2fbba0a7851
|
|
| MD5 |
05804caa32b5d82253faad325abcdf39
|
|
| BLAKE2b-256 |
1aad1a455040382ac96c3165556afcd9374618b671f6b9ee2aa90629f5fc6531
|