尝试运行TransitFlow / Processing,但出现错误

时间:2020-09-22 12:17:23

标签: python pandas processing

点击此链接后,我刚刚安装了TransitFlow和预处理:

https://github.com/transitland/transitland-processing-animation

然后运行以下代码:

python transitflow.py --name=chicago --bbox=-87.992249,41.605175,-87.302856,42.126747 --clip_to_bbox --exclude=o-9-amtrak,o-9-amtrakcharteredvehicle

一切正常,除了最后,我得到了这个错误:

success!
5 operators successfully downloaded.
0 operators failed.
Concatenating individual operator outputs.
Calculating trip segment bearings.
Traceback (most recent call last):
  File "C:\Users\Evan\Anaconda3\lib\site-packages\pandas\core\indexes\base.py", line 2891, 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 101, 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 "C:\Users\Evan\Anaconda3\lib\site-packages\pandas\core\generic.py", line 3571, in _set_item
    loc = self._info_axis.get_loc(key)
  File "C:\Users\Evan\Anaconda3\lib\site-packages\pandas\core\indexes\base.py", line 2893, 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 "C:\Users\Evan\Anaconda3\lib\site-packages\pandas\core\frame.py", line 3040, in __setitem__
    self._set_item(key, value)
  File "C:\Users\Evan\Anaconda3\lib\site-packages\pandas\core\frame.py", line 3117, in _set_item
    NDFrame._set_item(self, key, value)
  File "C:\Users\Evan\Anaconda3\lib\site-packages\pandas\core\generic.py", line 3574, in _set_item
    self._mgr.insert(len(self._info_axis), key, value)
  File "C:\Users\Evan\Anaconda3\lib\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 "C:\Users\Evan\Anaconda3\lib\site-packages\pandas\core\internals\blocks.py", line 2719, in make_block
    return klass(values, ndim=ndim, placement=placement)
  File "C:\Users\Evan\Anaconda3\lib\site-packages\pandas\core\internals\blocks.py", line 2375, in __init__
    super().__init__(values, ndim=ndim, placement=placement)
  File "C:\Users\Evan\Anaconda3\lib\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

数据来自此站点:https://transit.land/feed-registry/

我查看了transportflow.py,并检索了导致我遇到此错误的代码行(我认为):

 df['bearing'] = df.apply(lambda row: calc_bearing_between_points(row['start_lat'], row['start_lon'], row['end_lat'], row['end_lon']), axis=1)

有什么想法吗?

谢谢

0 个答案:

没有答案