Merge pull request #971 from koen-vg/fix-sanitize-locations

Only sanitize locations when there are buses with a location
This commit is contained in:
Fabian Neumann 2024-03-19 08:26:24 +01:00 committed by GitHub
commit db4219f4d5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -184,12 +184,13 @@ def sanitize_carriers(n, config):
def sanitize_locations(n):
n.buses["x"] = n.buses.x.where(n.buses.x != 0, n.buses.location.map(n.buses.x))
n.buses["y"] = n.buses.y.where(n.buses.y != 0, n.buses.location.map(n.buses.y))
n.buses["country"] = n.buses.country.where(
n.buses.country.ne("") & n.buses.country.notnull(),
n.buses.location.map(n.buses.country),
)
if "location" in n.buses.columns:
n.buses["x"] = n.buses.x.where(n.buses.x != 0, n.buses.location.map(n.buses.x))
n.buses["y"] = n.buses.y.where(n.buses.y != 0, n.buses.location.map(n.buses.y))
n.buses["country"] = n.buses.country.where(
n.buses.country.ne("") & n.buses.country.notnull(),
n.buses.location.map(n.buses.country),
)
def add_co2_emissions(n, costs, carriers):