Traceback (most recent call last): File "E:\code-study\coda\cross_nostopline.py", line 72, in <module> dense_gdf.loc["geometry"] = dense_gdf.loc[geometry].buffer(buffer_size) File "C:\Users\GW00321286\.conda\envs\python_39\lib\site-packages\pandas\core\indexing.py", line 1073, in __getitem__ return self._getitem_axis(maybe_callable, axis=axis) File "C:\Users\GW00321286\.conda\envs\python_39\lib\site-packages\pandas\core\indexing.py", line 1301, in _getitem_axis return self._getitem_iterable(key, axis=axis) File "C:\Users\GW00321286\.conda\envs\python_39\lib\site-packages\pandas\core\indexing.py", line 1239, in _getitem_iterable keyarr, indexer = self._get_listlike_indexer(key, axis) File "C:\Users\GW00321286\.conda\envs\python_39\lib\site-packages\pandas\core\indexing.py", line 1432, in _get_listlike_indexer keyarr, indexer = ax._get_indexer_strict(key, axis_name) File "C:\Users\GW00321286\.conda\envs\python_39\lib\site-packages\pandas\core\indexes\base.py", line 6070, in _get_indexer_strict self._raise_if_missing(keyarr, indexer, axis_name) File "C:\Users\GW00321286\.conda\envs\python_39\lib\site-packages\pandas\core\indexes\base.py", line 6130, in _raise_if_missing raise KeyError(f"None of [{key}] are in the [{axis_name}]") KeyError: "None of [Index([POINT (345888.8377459495 3449498.849251645),\n POINT (345629.9746449967 3449407.506965276),\n POINT (345280.0915703106 3449030.03372914),\n POINT (345272.4912822249 3449049.808989464),\n POINT (345272.4912822249 3449049.808989464),\n POINT (345207.976594619 3449222.778335579),\n POINT (346000.1694985296 3449534.672827335),\n POINT (345945.905299675 3449515.56654852),\n POINT (345912.594155262 3449503.834785844),\n POINT (345630.9943146321 3449404.431732289),\n ...\n POINT (345277.9022990875 3449028.592923693),\n POINT (345204.7713578056 3449221.296469824),\n POINT (346339.6048540358 3449370.035821553),\n POINT (346279.8118892043 3449595.525410736),\n POINT (345380.252806792 3449988.001190433),\n POINT (345401.3998641131 3449929.891882143),\n POINT (346343.3549850415 3449369.732726835),\n POINT (346283.1624534061 3449596.718543904),\n POINT (345393.3268300895 3449992.281861236),\n POINT (345414.9814342285 3449932.569705966)],\n dtype='object', length=186)] are in the [index]"
时间: 2023-08-22 10:04:49 浏览: 66
这是一段Python的Traceback信息,其中包含了出错的位置和原因。
根据Traceback信息,可以看出在第72行代码中,出现了KeyError。具体原因是,在对dense_gdf进行切片时,使用了一个不存在于DataFrame索引中的键值,导致了KeyError的出现。
建议你检查一下代码中相关变量和索引的定义,确保使用的键值都存在于DataFrame中。
相关问题
C:\Users\GW00321286\.conda\envs\python_39\python.exe E:\code-study\coda\cross_nostopline.py Traceback (most recent call last): File "E:\code-study\coda\cross_nostopline.py", line 37, in <module> nearest_point = find_nearest_point(gdf,point) File "E:\code-study\coda\cross_nostopline.py", line 25, in find_nearest_point buffer = point.buffer(3.5) File "C:\Users\GW00321286\.conda\envs\python_39\lib\site-packages\pandas\core\generic.py", line 5902, in __getattr__ return object.__getattribute__(self, name) AttributeError: 'Series' object has no attribute 'buffer'
这看起来像是一个 Python 的错误信息。根据错误信息,似乎是在执行 cross_nostopline.py 这个文件时出现了问题。具体来说,代码中的第 25 行调用了一个名为 buffer 的方法,但是该方法似乎不适用于 Series 对象。可能需要检查一下代码,看看是否正确地处理了 Series 对象和其他数据类型之间的转换。
Traceback (most recent call last): File "E:\code-study\coda\cross_nostopline.py", line 18, in <module> piont = list(Point(coords_list)) File "C:\Users\GW00321286\.conda\envs\python_39\lib\site-packages\shapely\geometry\point.py", line 73, in __new__ raise ValueError( ValueError: Point() takes only scalar or 1-size vector arguments
这个错误的意思是`Point()`函数只接受标量或者长度为1的向量作为参数,但是你传递给它的参数`coords_list`不符合这个要求。可能的原因是`coords_list`不是一个标量或者长度为1的向量。
你需要检查一下你传递给`Point()`函数的参数`coords_list`的类型和形状是否正确。如果`coords_list`是一个列表,那么你需要确保它的长度为1,或者是一个包含两个标量的列表。如果`coords_list`是一个NumPy数组,那么你需要确保它的形状为(1, 2)。
另外,你也可以考虑使用`Point()`函数的另一个构造函数`Point(x, y)`,它接受两个标量作为参数,分别表示点的x和y坐标。你可以根据自己的需要选择合适的构造函数来创建点对象。