Note
Go to the end to download the full example code.
Analyze a trip table#
This example shows how to: - Analyze a trip table after it has been generated by Polaris - Analyze a trip table from file (exogenous trips)
Imports
from pathlib import Path
import pandas as pd
from polaris import Polaris
from polaris.analyze.demand_report import demand_report
from polaris.utils.database.data_table_access import DataTableAccess
model_dir = Path("/tmp/Austin")
supply_file = Polaris.from_dir(model_dir).supply_file
demand_file = Polaris.from_dir(model_dir).demand_file
Read Locations table from the Supply database
dta = DataTableAccess(supply_file)
locations = dta.get("Location")
Read trip table from the Exogenous file
trips = pd.read_csv(model_dir / "demand/trip.zip")
# Reading from the demand database is also easy:
# dta_demand = DataTableAccess(demand_file)
# trips = dta_demand.get("Trip")
Now we can run the demand report analysis on the trip table
report = demand_report(trips=trips, locations=locations)

/venv-py312/lib/python3.12/site-packages/aequilibrae/paths/graph.py:218: ChainedAssignmentError: A value is being set on a copy of a DataFrame or Series through chained assignment.
Such chained assignment never works to update the original DataFrame or Series, because the intermediate object on which we are setting values always behaves as a copy (due to Copy-on-Write).
Try using '.loc[row_indexer, col_indexer] = value' instead, to perform the assignment in a single step.
See the documentation for a more detailed explanation: https://pandas.pydata.org/pandas-docs/stable/user_guide/copy_on_write.html#chained-assignment
build_compressed_graph(self, remove_dead_ends)
delaunay : 0%| | 0/2102 [00:00<?, ?it/s]
Equilibrium Assignment : 0%| | 0/250 [00:00<?, ?it/s]
We can save the report to disk if we want
report.savefig(model_dir / "report_demand.png", dpi=600)
Total running time of the script: (0 minutes 27.605 seconds)