Skip to content

transitlos.equity

Pure population-weighted equity statistics over a combined access/population table.

No I/O, no dependency on any other transitlos module or the sibling packages -- only numpy/pandas. Takes whatever transitlos.population.cross_with_population (or any DataFrame with the same two columns) produces.

equity_statistics(combined_gdf, score_col='level_of_service', population_col='population', groups=None, thresholds=(0.25, 0.5, 0.75))

Compute population-weighted access-equity statistics.

Parameters:

Name Type Description Default
combined_gdf DataFrame

DataFrame/GeoDataFrame with score_col and population_col columns (e.g. from transitlos.population.cross_with_population).

required
score_col str

Column holding the per-row level of service.

'level_of_service'
population_col str

Column holding the per-row population count, used as weights throughout.

'population'
groups Optional[Union[str, Sequence[str]]]

Optional column name (or list of column names) to also break statistics down by, in addition to the overall figures.

None
thresholds Sequence[float]

Score thresholds used to report the population share above/below each one.

(0.25, 0.5, 0.75)

Returns:

Type Description
dict

A dict with keys "overall" (a dict of weighted_mean,

dict

weighted_median, gini, and pct_population_above_threshold/

dict

pct_population_below_threshold sub-dicts keyed by threshold), and,

dict

if groups was given, "by_group": a pandas.DataFrame indexed by

dict

the group column(s) with the same statistics per group.