transitland-processing-animation icon indicating copy to clipboard operation
transitland-processing-animation copied to clipboard

error running the example: pandas: Wrong number of items passed 8, placement implies 1

Open wangjiahong opened this issue 3 years ago • 2 comments

Hi, I was running following example code, python transitflow.py --name=san_francisco --bbox=-122.515411,37.710714,-122.349243,37.853983 --clip_to_bbox --date=2020-01-01

But I see following error: image

I try to fix it, but don't know where is the problem. Would really appreciate if anyone could help me. @bcamper @drewda @irees @meghanhade @Danie error

`
INPUTS:
date:  2020-01-01
name:  san_francisco
API key:  None
bbox:  -122.515411 37.710714 -122.349243 37.853983
http://transit.land/api/v1/operators?bbox=-122.515411%2C37.710714%2C-122.349243%2C37.853983&per_page=10000
18 operators in bounding box.
18 operators to be downloaded.
b'o-9q8zm-blue~goldfleet' 1 / 18
http://transit.land/api/v1/routes?operated_by=o-9q8zm-blue~goldfleet&per_page=10000
6 routes found.

http://transit.land/api/v1/stops?served_by=o-9q8zm-blue~goldfleet&per_page=10000
6 stops found.

http://transit.land/api/v1/schedule_stop_pairs?operator_onestop_id=o-9q8zm-blue~goldfleet&date=2020-01-01&per_page=10000&sort_min_id=0
0 schedule stop pairs found.

success!
b'o-9q9j-commuteorgshuttles' 2 / 18
http://transit.land/api/v1/routes?operated_by=o-9q9j-commuteorgshuttles&per_page=10000
0 routes found.

http://transit.land/api/v1/stops?served_by=o-9q9j-commuteorgshuttles&per_page=10000
0 stops found.

http://transit.land/api/v1/schedule_stop_pairs?operator_onestop_id=o-9q9j-commuteorgshuttles&date=2020-01-01&per_page=10000&sort_min_id=0
0 schedule stop pairs found.

success!
b'o-9q9-caltrain' 3 / 18
http://transit.land/api/v1/routes?operated_by=o-9q9-caltrain&per_page=10000
10 routes found.

http://transit.land/api/v1/stops?served_by=o-9q9-caltrain&per_page=10000
66 stops found.

http://transit.land/api/v1/schedule_stop_pairs?operator_onestop_id=o-9q9-caltrain&date=2020-01-01&per_page=10000&sort_min_id=0
0 schedule stop pairs found.

success!
b'o-9q8zn-alcatrazhornblowerferry' 4 / 18
http://transit.land/api/v1/routes?operated_by=o-9q8zn-alcatrazhornblowerferry&per_page=10000
3 routes found.

http://transit.land/api/v1/stops?served_by=o-9q8zn-alcatrazhornblowerferry&per_page=10000
2 stops found.

http://transit.land/api/v1/schedule_stop_pairs?operator_onestop_id=o-9q8zn-alcatrazhornblowerferry&date=2020-01-01&per_page=10000&sort_min_id=0
0 schedule stop pairs found.

success!
b'o-9q8zr-tidelinewatertaxi' 5 / 18
http://transit.land/api/v1/routes?operated_by=o-9q8zr-tidelinewatertaxi&per_page=10000
3 routes found.

http://transit.land/api/v1/stops?served_by=o-9q8zr-tidelinewatertaxi&per_page=10000
4 stops found.

http://transit.land/api/v1/schedule_stop_pairs?operator_onestop_id=o-9q8zr-tidelinewatertaxi&date=2020-01-01&per_page=10000&sort_min_id=0
0 schedule stop pairs found.

success!
b'o-9qbb-marintransit' 6 / 18
http://transit.land/api/v1/routes?operated_by=o-9qbb-marintransit&per_page=10000
31 routes found.

http://transit.land/api/v1/stops?served_by=o-9qbb-marintransit&per_page=10000
923 stops found.

http://transit.land/api/v1/schedule_stop_pairs?operator_onestop_id=o-9qbb-marintransit&date=2020-01-01&per_page=10000&sort_min_id=0
0 schedule stop pairs found.

success!
b'o-9q9-actransit' 7 / 18
http://transit.land/api/v1/routes?operated_by=o-9q9-actransit&per_page=10000
174 routes found.

http://transit.land/api/v1/stops?served_by=o-9q9-actransit&per_page=10000
5631 stops found.

http://transit.land/api/v1/schedule_stop_pairs?operator_onestop_id=o-9q9-actransit&date=2020-01-01&per_page=10000&sort_min_id=0
0 schedule stop pairs found.

success!
b'o-9q8y-sfmta' 8 / 18
http://transit.land/api/v1/routes?operated_by=o-9q8y-sfmta&per_page=10000
110 routes found.

http://transit.land/api/v1/stops?served_by=o-9q8y-sfmta&per_page=10000
3712 stops found.

http://transit.land/api/v1/schedule_stop_pairs?operator_onestop_id=o-9q8y-sfmta&date=2020-01-01&per_page=10000&sort_min_id=0
0 schedule stop pairs found.

success!
b'o-9q8z-goldengateferry' 9 / 18
http://transit.land/api/v1/routes?operated_by=o-9q8z-goldengateferry&per_page=10000
8 routes found.

http://transit.land/api/v1/stops?served_by=o-9q8z-goldengateferry&per_page=10000
4 stops found.

http://transit.land/api/v1/schedule_stop_pairs?operator_onestop_id=o-9q8z-goldengateferry&date=2020-01-01&per_page=10000&sort_min_id=0
0 schedule stop pairs found.

success!
b'o-9qc-westcatwesterncontracosta' 10 / 18
http://transit.land/api/v1/routes?operated_by=o-9qc-westcatwesterncontracosta&per_page=10000
16 routes found.

http://transit.land/api/v1/stops?served_by=o-9qc-westcatwesterncontracosta&per_page=10000
227 stops found.

http://transit.land/api/v1/schedule_stop_pairs?operator_onestop_id=o-9qc-westcatwesterncontracosta&date=2020-01-01&per_page=10000&sort_min_id=0
0 schedule stop pairs found.

success!
b'o-9q8-samtrans' 11 / 18
http://transit.land/api/v1/routes?operated_by=o-9q8-samtrans&per_page=10000
98 routes found.

http://transit.land/api/v1/stops?served_by=o-9q8-samtrans&per_page=10000
2259 stops found.

http://transit.land/api/v1/schedule_stop_pairs?operator_onestop_id=o-9q8-samtrans&date=2020-01-01&per_page=10000&sort_min_id=0
0 schedule stop pairs found.

success!
b'o-9q9p-sanfranciscobayferry' 12 / 18
http://transit.land/api/v1/routes?operated_by=o-9q9p-sanfranciscobayferry&per_page=10000
15 routes found.

http://transit.land/api/v1/stops?served_by=o-9q9p-sanfranciscobayferry&per_page=10000
15 stops found.

http://transit.land/api/v1/schedule_stop_pairs?operator_onestop_id=o-9q9p-sanfranciscobayferry&date=2020-01-01&per_page=10000&sort_min_id=0
0 schedule stop pairs found.

success!
b'o-9q8v-commuteorgshuttle' 13 / 18
http://transit.land/api/v1/routes?operated_by=o-9q8v-commuteorgshuttle&per_page=10000
26 routes found.

http://transit.land/api/v1/stops?served_by=o-9q8v-commuteorgshuttle&per_page=10000
146 stops found.

http://transit.land/api/v1/schedule_stop_pairs?operator_onestop_id=o-9q8v-commuteorgshuttle&date=2020-01-01&per_page=10000&sort_min_id=0
0 schedule stop pairs found.

success!
b'o-9q8yy-missionbaytma' 14 / 18
http://transit.land/api/v1/routes?operated_by=o-9q8yy-missionbaytma&per_page=10000
0 routes found.

http://transit.land/api/v1/stops?served_by=o-9q8yy-missionbaytma&per_page=10000
0 stops found.

http://transit.land/api/v1/schedule_stop_pairs?operator_onestop_id=o-9q8yy-missionbaytma&date=2020-01-01&per_page=10000&sort_min_id=0
0 schedule stop pairs found.

success!
b'o-9qb-goldengatetransit' 15 / 18
http://transit.land/api/v1/routes?operated_by=o-9qb-goldengatetransit&per_page=10000
44 routes found.

http://transit.land/api/v1/stops?served_by=o-9qb-goldengatetransit&per_page=10000
794 stops found.

http://transit.land/api/v1/schedule_stop_pairs?operator_onestop_id=o-9qb-goldengatetransit&date=2020-01-01&per_page=10000&sort_min_id=0
0 schedule stop pairs found.

success!
b'o-9qc-capitolcorridor' 16 / 18
http://transit.land/api/v1/routes?operated_by=o-9qc-capitolcorridor&per_page=10000
4 routes found.

http://transit.land/api/v1/stops?served_by=o-9qc-capitolcorridor&per_page=10000
23 stops found.

http://transit.land/api/v1/schedule_stop_pairs?operator_onestop_id=o-9qc-capitolcorridor&date=2020-01-01&per_page=10000&sort_min_id=0
0 schedule stop pairs found.

success!
b'o-9q9-bart' 17 / 18
http://transit.land/api/v1/routes?operated_by=o-9q9-bart&per_page=10000
19 routes found.

http://transit.land/api/v1/stops?served_by=o-9q9-bart&per_page=10000
98 stops found.

http://transit.land/api/v1/schedule_stop_pairs?operator_onestop_id=o-9q9-bart&date=2020-01-01&per_page=10000&sort_min_id=0
0 schedule stop pairs found.

success!
b'o-9qb-sonomacountyairportexpress' 18 / 18
http://transit.land/api/v1/routes?operated_by=o-9qb-sonomacountyairportexpress&per_page=10000
0 routes found.

http://transit.land/api/v1/stops?served_by=o-9qb-sonomacountyairportexpress&per_page=10000
0 stops found.

http://transit.land/api/v1/schedule_stop_pairs?operator_onestop_id=o-9qb-sonomacountyairportexpress&date=2020-01-01&per_page=10000&sort_min_id=0
0 schedule stop pairs found.

success!
18 operators successfully downloaded.
0 operators failed.
Concatenating individual operator outputs.
Calculating trip segment bearings.
Traceback (most recent call last):
  File "/Users/home/Documents/transitland-processing-animation/venv_transit/lib/python3.7/site-packages/pandas/core/indexes/base.py", line 2889, in get_loc
    return self._engine.get_loc(casted_key)
  File "pandas/_libs/index.pyx", line 70, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/index.pyx", line 97, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/hashtable_class_helper.pxi", line 1675, in pandas._libs.hashtable.PyObjectHashTable.get_item
  File "pandas/_libs/hashtable_class_helper.pxi", line 1683, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'bearing'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/home/Documents/transitland-processing-animation/venv_transit/lib/python3.7/site-packages/pandas/core/generic.py", line 3565, in _set_item
    loc = self._info_axis.get_loc(key)
  File "/Users/home/Documents/transitland-processing-animation/venv_transit/lib/python3.7/site-packages/pandas/core/indexes/base.py", line 2891, in get_loc
    raise KeyError(key) from err
KeyError: 'bearing'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "transitflow.py", line 406, in <module>
    df['bearing'] = df.apply(lambda row: calc_bearing_between_points(row['start_lat'], row['start_lon'], row['end_lat'], row['end_lon']), axis=1)
  File "/Users/home/Documents/transitland-processing-animation/venv_transit/lib/python3.7/site-packages/pandas/core/frame.py", line 3040, in __setitem__
    self._set_item(key, value)
  File "/Users/home/Documents/transitland-processing-animation/venv_transit/lib/python3.7/site-packages/pandas/core/frame.py", line 3117, in _set_item
    NDFrame._set_item(self, key, value)
  File "/Users/home/Documents/transitland-processing-animation/venv_transit/lib/python3.7/site-packages/pandas/core/generic.py", line 3568, in _set_item
    self._mgr.insert(len(self._info_axis), key, value)
  File "/Users/home/Documents/transitland-processing-animation/venv_transit/lib/python3.7/site-packages/pandas/core/internals/managers.py", line 1189, in insert
    block = make_block(values=value, ndim=self.ndim, placement=slice(loc, loc + 1))
  File "/Users/home/Documents/transitland-processing-animation/venv_transit/lib/python3.7/site-packages/pandas/core/internals/blocks.py", line 2714, in make_block
    return klass(values, ndim=ndim, placement=placement)
  File "/Users/home/Documents/transitland-processing-animation/venv_transit/lib/python3.7/site-packages/pandas/core/internals/blocks.py", line 2370, in __init__
    super().__init__(values, ndim=ndim, placement=placement)
  File "/Users/home/Documents/transitland-processing-animation/venv_transit/lib/python3.7/site-packages/pandas/core/internals/blocks.py", line 130, in __init__
    f"Wrong number of items passed {len(self.values)}, "
ValueError: Wrong number of items passed 8, placement implies 1
`

wangjiahong avatar Aug 29 '20 14:08 wangjiahong

I am running on Mac os catalina 10.15.4

wangjiahong avatar Aug 29 '20 14:08 wangjiahong

@wangjiahong I am getting the same error, were you ever able to find a solution to this?

garcia-joseph avatar Jul 08 '22 16:07 garcia-joseph