iduedu.aggregate_objects¶
- iduedu.aggregate_objects(urban_graph, cutoff, *, gdf_origins=None, gdf_objects=None, origins_nodes=None, object_nodes=None, columns=None, weight='time_min', decay=None, beta=None, direction='from', graph_node_column='graph_node_id', max_workers=None)[source]¶
Count objects and sum their values within a travel cost of every origin.
With
decayevery object counts with a weight that falls with its travel costd:"linear"is1 - d / cutoff,"exp"isexp(-beta * d)and"inverse"is1 / d(objects at cost 0 are left out). Sums and counts are then weighted, and means are weighted means.- Parameters:
urban_graph (
UrbanGraph) – Graph to search.cutoff (
Union[float,Iterable[float]]) – Largest travel cost, inclusive, or several of them; every cutoff gives its own columns.gdf_origins (
DataFrame|None) – Origin objects, withgraph_node_columnor matched to their nearest nodes, orgdf_objects (
DataFrame|None) – Objects to aggregate, with the same conventions, orobject_nodes (
Optional[Iterable[Any]]) – their node ids (counts only).columns (
Optional[Iterable[str]]) – Numeric columns ofgdf_objectsto sum and average. Missing values are left out.weight (
Literal['length_meter','time_min']) – Edge cost column:time_min(minutes) orlength_meter(metres).decay (
Optional[Literal['linear','exp','inverse']]) – Distance decay of the weights, orNonefor none.beta (
Union[float,Iterable[float],None]) – Rate of the exponential decay, one value or one per cutoff. By default4 / cutoff, which leaves a weight of 0.018 at the cutoff.direction (
Literal['from','to']) –"from"measures the way from the origin to the object,"to"from the object to the origin. They differ on directed graphs.graph_node_column (
str) – Column of object tables that holds graph node ids.max_workers (
int|None) – Number of threads;Noneuses all cores.
- Returns:
count_cand, for each ofcolumns,<column>_sum_cand<column>_mean_c(NaNwhere nothing is in reach).- Return type:
DataFrame indexed like the origins. For every cutoff
c- Raises:
ValueError – If
cutoff,decayordirectionis invalid, orcolumnsis passed withoutgdf_objects.KeyError – If a column is absent from
gdf_objects.