See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy super().__setitem__(key, value) Traceback (most recent call last): File "E:\code-study\coda\cross_nostopline.py", line 74, in <module> for index,row in dense_gdf["buffer_polygon"].iterrows(): 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: 'GeoSeries' object has no attribute 'iterrows'
时间: 2023-09-11 10:08:53 浏览: 301
根据您的描述,这个错误的原因是因为您正在尝试在GeoSeries对象上使用iterrows()方法,而GeoSeries对象没有这个方法。相反,您可以使用GeoSeries对象自己的迭代器来迭代它的值。例如,您可以使用for循环来迭代GeoSeries对象中的每个值。例如:
```
for value in dense_gdf["buffer_polygon"]:
# Do something with value
```
或者,您可以将GeoSeries对象转换为DataFrame对象,然后使用DataFrame对象上的iterrows()方法。例如:
```
for index, row in dense_gdf.to_frame().iterrows():
# Do something with row
```
希望这可以帮助您解决问题!
相关问题
see the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
在文档中查看警告:https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/pandas/core/indexing.py:1596: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy self.obj[key] = _infer_fill_value(value) /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/pandas/core/indexing.py:1763: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy isetter(loc, value)
这是一个 pandas 库的警告信息,通常出现在使用索引对 DataFrame 进行切片并赋值操作时。警告信息的意思是,用户试图对一个 DataFrame 对象的一个切片进行赋值操作,但是该操作会先对切片对象进行一次复制操作(copy),然后再对复制出来的对象进行赋值。这样的操作可能会导致意外修改原始数据或者引用错误的数据。为了避免这种风险,建议使用 .loc 或 .iloc 操作符进行赋值操作。同时,也可以在操作前使用 .copy() 方法对 DataFrame 对象进行显式的复制操作,以避免警告信息的出现。
阅读全文