python - AttributeError:在 geopandas 中绘图时,“PandasArray”对象没有属性“_str_startswith”
问题描述
我不得不重新设置我的 python 环境并收到以下错误消息:
AttributeError:“PandasArray”对象没有属性“_str_startswith”
当我尝试使用基本的 GeoDataFrame.plot() 函数时
geoDF= geopandas.readfile('myfile.geojson')
geoDF.plot()
我已经更新了 pandas、matplotlib、numpy、geopandas,但仍然遇到同样的问题。
~\anaconda3\lib\site-packages\geopandas\geodataframe.py in plot(self, *args, **kwargs)
919 from there.
920 """
--> 921 return plot_dataframe(self, *args, **kwargs)
922
923 plot.__doc__ = plot_dataframe.__doc__
~\anaconda3\lib\site-packages\geopandas\plotting.py in plot_dataframe(df, column, cmap, color, ax, cax, categorical, legend, scheme, k, vmin, vmax, markersize, figsize, legend_kwds, categories, classification_kwds, missing_kwds, aspect, **style_kwds)
613
614 if column is None:
--> 615 return plot_series(
616 df.geometry,
617 cmap=cmap,
~\anaconda3\lib\site-packages\geopandas\plotting.py in plot_series(s, cmap, color, ax, figsize, aspect, **style_kwds)
388
389 # decompose GeometryCollections
--> 390 geoms, multiindex = _flatten_multi_geoms(s.geometry, prefix="Geom")
391 values = np.take(values, multiindex, axis=0) if cmap else None
392 expl_series = geopandas.GeoSeries(geoms)
~\anaconda3\lib\site-packages\geopandas\plotting.py in _flatten_multi_geoms(geoms, prefix)
42 components, component_index = [], []
43
---> 44 if not geoms.geom_type.str.startswith(prefix).any():
45 return geoms, np.arange(len(geoms))
46
~\anaconda3\lib\site-packages\pandas\core\strings\accessor.py in wrapper(self, *args, **kwargs)
99 )
100 raise TypeError(msg)
--> 101 return func(self, *args, **kwargs)
102
103 wrapper.__name__ = func_name
~\anaconda3\lib\site-packages\pandas\core\strings\accessor.py in startswith(self, pat, na)
2070 dtype: bool
2071 """
-> 2072 result = self._array._str_startswith(pat, na=na)
2073 return self._wrap_result(result, returns_string=False)
2074
AttributeError: 'PandasArray' object has no attribute '_str_startswith'
谢谢!
解决方案
已经解决了!必须将 pandas 更新到 1.2.0 版本,然后安装笛卡尔包。
推荐阅读
- javascript - Ajax 的数据和 fetch API 的主体有什么区别?
- ruby-on-rails - 在 Rails ActiveRecord 中为每个枚举值赋予多个属性
- reactjs - 无法导入 FieldInputProps react-final-form
- dataweave - 如何在dataweave中获取动态列
- c# - 有哪些选项可以不为 ASP .NET Core Razor 页面上的文件浏览器重新加载整个页面?
- java - 未能执行目标 org.codehaus.mojo:exec-maven-plugin:3.0.0
- python - Python - 有没有一种方法可以使用 Openpyxl 动态处理 Excel 文件中的数据
- html - 有没有办法覆盖css样式表?
- c# - Firebase 致命异常
- django - 模态表单未在 Django 中显示