A Python library providing a uniform interface to Living Standards Measurement Study (LSMS) household surveys from multiple countries and years, without the data loss typical of traditional harmonization approaches.
LSMS datasets are invaluable for studying poverty, consumption, and household welfare across developing countries. However, each country’s survey uses different:
- Variable names and encodings
- Food classification systems
- Questionnaire structures
- File formats and organization
Researchers typically spend weeks learning each new dataset’s idiosyncrasies or use pre-harmonized datasets that sacrifice detail and comparability. Cross-country or longitudinal analyses become prohibitively time-consuming.
LSMS_Library provides an abstraction layer that gives you a consistent interface to work with any supported LSMS dataset. Instead of harmonizing the data itself (which loses information), we harmonize the way you access the data.
From PyPI (when available):
pip install LSMS_LibraryFrom github (current release):
pip install git+https://github.com/ligon/LSMS_Library.git@v0.7.0From a source checkout (for contributors):
git clone https://github.com/ligon/LSMS_Library.git
cd LSMS_Library
poetry installimport lsms_library as ll
# Single-country access
uga = ll.Country('Uganda')
uga.waves # ['2005-06', '2009-10', ..., '2019-20']
uga.data_scheme # ['food_acquired', 'household_roster', ...]
food = uga.food_expenditures() # Standardized DataFrame, all waves
# Cross-country analysis
roster = ll.Feature('household_roster')
roster.countries # ['Burkina_Faso', 'Ethiopia', 'Mali', 'Uganda', ...]
df = roster() # Harmonized DataFrame across all countriesThis library abstracts over Living Standards Measurement Study (LSMS) survey data. The underlying microdata belongs to the respective national statistics offices and the World Bank; users must accept the World Bank Microdata Library’s terms of use before accessing it.
- Register at https://microdata.worldbank.org/ (free).
- Accept the terms of use for the LSMS collections you want to access.
- Get your API key from your account dashboard.
- Create
~/.config/lsms_library/config.ymlwith:microdata_api_key: your_key_here # data_dir: /path/to/override # same as LSMS_DATA_DIR env var
or set
MICRODATA_API_KEYas an environment variable. - On
import lsms_library, the library validates your key against the WB catalog and automatically unlocks access to the S3 read cache. No further setup is required.
Once your WB API key is validated, the library unlocks a read-only S3 cache that mirrors the WB Microdata downloads. This is a convenience – the S3 cache is faster than the WB NADA API and reduces load on the WB service – but it is not a separate access layer. The WB terms of use are the authoritative gate; the S3 cache just provides the same data faster.
Decrypted plaintext credentials are written to ~/.config/lsms_library/s3_creds (or the path in the LSMS_S3_CREDS environment variable), not into the package tree – so the library is safe to install from a wheel into a read-only site-packages directory.
In CI, Docker builds, or other non-interactive contexts, set LSMS_SKIP_AUTH=1 to suppress the import-time authentication flow. In that mode you are responsible for ensuring ~/.config/lsms_library/s3_creds exists (e.g. via a CI secret mount) before the first data access.
Parquet caches materialize under the platform-appropriate user data directory:
- Linux:
~/.local/share/lsms_library/by default - Override with
LSMS_DATA_DIRenv var ordata_dirinconfig.yml
See the caching guide for details on assume_cache_fresh, the Country and Feature classes, and per-country build methods.
Full documentation is available at ligon.github.io/LSMS_Library, including:
- **Getting Started** – installation and first steps
- **Country Guide** – single-country workflows, harmonization pipeline, derived tables
- **Feature Guide** – cross-country analysis with
ll.Feature - **Caching** – performance tuning, build backends, cache management
- **Panel Data** – longitudinal analysis and ID harmonization
- **API Reference** – complete class documentation (auto-generated from source)
See CONTRIBUTING.org for detailed guidelines on adding new datasets using DVC.
If you use LSMS_Library in your research, please cite:
@software{ligon25:lsms_library,
author = {Ethan Ligon},
title = {{\tt LSMS_Library}: Abstraction layer for working with Living Standards Measurement Surveys},
year = 2025,
doi = {10.5281/zenodo.17258079},
url = {https://pypi.org/project/lsms_library/}
}See the LICENSE file in the repository for details.
This project builds on data collection efforts by:
- The World Bank’s Living Standards Measurement Study (LSMS) team
- National statistical offices in participating countries
- The LSMS-ISA initiative