Skip to content

Example code creating an error in 'stop_I' for stops #17

@BeishuizenTimKPMG

Description

@BeishuizenTimKPMG

The stop ids in the example are taken from the index in the pandas dataframe instead of the 'stop_I' column. This is not a problem in the Finnish dataset, but not all ids are the same the index number. (for example. the Dutch public transport dataset from www.openOV.nl starts with 1 instead of 0)

Code change proposals:

stop_dict = G.stops().to_dict("index")
for stop_I, data in stop_dict.items():
    if data['name'] == from_stop_name:
        from_stop_I = stop_I
    if data['name'] == to_stop_name:
        to_stop_I = stop_I
assert (from_stop_I is not None)
assert (to_stop_I is not None)

TO:

stop_data = OV_data.stops()

from_stop_I = stop_data[stop_data['name'] == from_stop_name].stop_I.values[0]
to_stop_I = stop_data[stop_data['name'] == to_stop_name].stop_I.values[0]

AND FROM:

stop_dict = G.stops().to_dict("index")
print("Origin: ", stop_dict[from_stop_I])
print("Destination: ", stop_dict[to_stop_I])

TO:

stop_data = OV_data.stops()
print("Origin: ", stop_data[stop_data['stop_I'] == from_stop_I])
print("Destination: ", stop_data[stop_data['stop_I'] == to_stop_I])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions