Skip to content

Feature

Feature

Feature(table_name: str, trust_cache: bool = False)

Assemble a single harmonized DataFrame for a table across countries.

Parameters:

Name Type Description Default
table_name str

The table to load (e.g. 'household_roster', 'cluster_features').

required
trust_cache bool

If True, read existing cached parquets without validation (fast). Can be overridden per-call. Default False.

False

Examples:

>>> import lsms_library as ll
>>> roster = ll.Feature('household_roster')
>>> roster.countries          # which countries have this table
>>> df = roster(['Mali', 'Uganda'])  # load specific countries
>>> df = roster()                    # load all available countries
>>> df = roster(trust_cache=True)    # fast read from cache

countries property

countries: list[str]

Countries that declare this table in their data_scheme.yml.

columns property

columns: list[str]

Required columns from the global data_info.yml for this table.

__call__

__call__(countries: list[str] | None = None, trust_cache: bool | None = None, currency: str | None = 'index', numeraire: str | None = None, **kwargs: Any) -> pd.DataFrame

Load and concatenate data across countries.

Parameters:

Name Type Description Default
countries list of str

Countries to include. Defaults to all available countries.

None
trust_cache bool

If True, read existing cached parquets without validation. Defaults to the instance-level setting from __init__.

None
currency ('index', 'column', None)

Attach the ISO 4217 currency code to monetary tables. Defaults to 'index' here (cross-country stacking is exactly where mixed currencies are silently incommensurable) -- unlike single-country Country(...) calls, which default to None. A no-op for non-monetary tables (there is nothing to label). See :func:lsms_library.currency.attach_currency.

'index'
numeraire str

Convert monetary columns to a comparable basis -- a target column of conversion_factors.org (e.g. 'PPP-2017'). Supersedes currency (the converted frame is labelled with the target). A no-op for non-monetary tables. See :func:lsms_library.conversion.convert.

None
**kwargs Any

Any other per-feature option the underlying Country(...).<table> method accepts (e.g. market, labels, units, age_cuts) is forwarded to each country (GH #508 -- Feature mirrors the Country method interface, swapping waves -> countries). market adds an m index level across countries. A kwarg a country's method does not accept is ignored with a warning.

{}

Returns:

Type Description
DataFrame

DataFrame with a country index level prepended.