add_names

add_names(df, groups=None, scale=None, ref=None)

Add the unit name and, for each scale in groups, the name of the unit it lies in.

Parameters

Name Type Description Default
df pd.DataFrame Any table with geo_id required
groups A coarser scale or list of them (see geo.ancestors), e.g. ["department"] None
scale str | None The units’ scale (default: inferred from geo_id) None

Returns

Name Type Description
pandas.DataFrame A copy with name and one column per group (the group unit’s name) after geo_id (and year).

Example

!pip install -q geo4bolivia
import geo4bolivia as geo
import plotly.express as px

df = geo.load("sdg08", variables="index_sdg8", years=2024)
df = geo.add_names(df, groups=["department", "province"])
px.box(df, x="department", y="index_sdg8", hover_name="name",
       labels=geo.labels(df), title="Decent work index, ~2024")