describe

describe(df, variables=None, by='year', ref=None)

Summary statistics of a panel’s variables, per by group (default: per year).

Parameters

Name Type Description Default
df pd.DataFrame A panel, e.g. from geo.load required
variables A variable or list of them (default: every numeric variable) None
by str | None A column to group by: "year" (default), None to pool all rows, or a group such as "department" (after geo.load(..., groups=["department"])) 'year'

Returns

Name Type Description
pandas.DataFrame One row per variable (and group): variable, label, unit, count, mean, std, min, p25, median, p75 and max.

Example

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

df = geo.load("sdg06", groups=["department"])
display(geo.describe(df))                          # per period
s = geo.describe(df, variables="index_sdg6", by="department")
px.bar(s, x="department", y="mean", error_y="std", labels={"mean": s["label"][0]},
       title="Clean water and sanitation index by department (both periods)")
variable label unit year count mean std min p25 median p75 max
0 index_sdg6 Clean water and sanitation index (0-100) index (0-100) 2012 343 26.248688 12.542797 0.0 18.65 25.5 33.40 76.9
1 index_sdg6 Clean water and sanitation index (0-100) index (0-100) 2024 343 41.769096 12.678638 10.8 33.80 40.9 48.30 86.9
2 sdg6_1_cap Drinking-water coverage (% of population) % of population 2012 343 66.276093 21.268711 1.5 54.25 69.7 82.30 99.3
3 sdg6_1_cap Drinking-water coverage (% of population) % of population 2024 343 80.339942 14.609916 21.5 73.80 84.1 90.55 99.0
4 sdg6_2_cas Sanitation coverage (% of population) % of population 2012 343 20.335860 12.438030 0.3 10.85 18.6 28.00 61.1
5 sdg6_2_cas Sanitation coverage (% of population) % of population 2024 343 46.281924 17.859282 4.8 33.00 45.4 59.25 87.2
6 sdg6_3_tar Wastewater treated (%) % of wastewater 2012 343 3.423907 18.610863 0.0 0.00 0.0 0.00 170.5
7 sdg6_3_tar Wastewater treated (%) % of wastewater 2024 343 6.962099 31.252333 0.0 0.00 0.0 0.00 401.4