extremes

extremes(data, variable, year=None, *, n=5, title=None, ref=None)

The units with the highest and the lowest values of a variable in one year.

Parameters

Name Type Description Default
data A dataset id, or a panel with geo_id (and year), e.g. from load required
variable str The numeric column to rank required
year The year to rank (default: the last with data) None
n int How many units to show at each end 5
title str | None The figure and table title None

Returns

Name Type Description
ExtremesResult A result with .df (the n highest and the n lowest units: geo_id, name, the group columns of the table, the variable, rank with 1 for the highest, and end: "highest" or "lowest"), .fig (horizontal bars, the two ends in different colours), .gt, .highest, .lowest, .median, .n_units (units with data), .year, .notes and .interpret().

Example

!pip install -q geo4bolivia
import geo4bolivia as geo

mpi = geo.load("sdg01", variables="sdg1_2_mpi", groups=["department"])
res = geo.extremes(mpi, "sdg1_2_mpi", year=2024, n=5)
print(res.interpret())
res.fig

Multidimensional poverty index (0-1) in 2024 ranges from 0.003 (Nuestra Señora de La Paz) to 0.296 (TIOC-Raqaypampa) across the 343 units with data; the median unit has 0.053.

The 5 highest: TIOC-Raqaypampa (0.296), Poroma (0.223), San Pedro (0.213), El Choro (0.203), Vila Vila (0.2).

The 5 lowest: Nuestra Señora de La Paz (0.003), Colcapirhua (0.005), Trigal (0.006), Santa Cruz de la Sierra (0.006), El Alto (0.006).

The gap between the two ends is 0.293. Extreme values deserve a second look before any analysis: they may be the most interesting units, very small units whose rates are noisy, or errors in the data.

These are associations, not causal effects. A causal reading needs a research design.