Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError: 'shape_pt_sequence' when trying to access feed.shapes #55

Open
tmein opened this issue Oct 31, 2024 · 0 comments
Open

KeyError: 'shape_pt_sequence' when trying to access feed.shapes #55

tmein opened this issue Oct 31, 2024 · 0 comments

Comments

@tmein
Copy link

tmein commented Oct 31, 2024

I am loading Transperth's GTFS data using this function:
loaded_feed = gtfs_functions.Feed(feed_path, time_windows=[0, 24], busiest_date=False, patterns=False)
and then trying to access loaded_feed.shapes. This throws the following exception:

  File "[snip]trunk\open_data_toolset\ingestor\__main__.py", line 15, in <module>
    data_processing.process(input_file=args.input, force=args.f)
  File "[snip]trunk\open_data_toolset\ingestor\data_processing\__init__.py", line 52, in process
    process_tool.get(data_tool, lambda *args: unknown_tool_error(data_tool))(config, force)
  File "[snip]trunk\open_data_toolset\ingestor\data_processing\gtfs.py", line 175, in process
    trips = parsing.load_gtfs_trips(os.path.join(base_path, location))
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "[snip]trunk\open_data_toolset\ingestor\data_processing\parsing.py", line 334, in load_gtfs_trips
    data = data.join(loaded_feed.shapes.set_index('shape_id'), on='shape_id', how='inner')
                     ^^^^^^^^^^^^^^^^^^
  File "[snip]venv-test\Lib\site-packages\gtfs_functions\gtfs_functions.py", line 213, in shapes
    self._shapes = self.get_shapes()
                   ^^^^^^^^^^^^^^^^^
  File "[snip]venv-test\Lib\site-packages\gtfs_functions\gtfs_functions.py", line 726, in get_shapes
    aux.sort_values(['shape_id','shape_pt_sequence'], inplace=True)
  File "[snip]venv-test\Lib\site-packages\pandas\util\_decorators.py", line 331, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "[snip]venv-test\Lib\site-packages\pandas\core\frame.py", line 6894, in sort_values
    keys = [self._get_label_or_level_values(x, axis=axis) for x in by]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "[snip]venv-test\Lib\site-packages\pandas\core\frame.py", line 6894, in <listcomp>
    keys = [self._get_label_or_level_values(x, axis=axis) for x in by]
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "[snip]venv-test\Lib\site-packages\pandas\core\generic.py", line 1850, in _get_label_or_level_values
    raise KeyError(key)
KeyError: 'shape_pt_sequence'

I'm not too familiar with GTFS, but I ran the data through https://gtfs-validator.mobilitydata.org and didn't receive any errors, and looking at shapes.txt shape_pt_sequence does appear to be there and populated. My code works with a variety of other Australian GTFS feeds and I couldn't find any obvious differences in their shapes.txt (although I may well be looking in the wrong place)

I'm using gtfs-functions 2.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant