属性错误:"熊猫数组"对象在地理熊猫中绘图时没有属性"_str_startswith"



我不得不重新设置我的python环境,我得到了以下错误消息:

属性错误:"PandasArray"对象没有属性"_str_startswith"

当我尝试使用基本的GeoDataFrame.plot((函数时

geoDF= geopandas.readfile('myfile.geojson')
geoDF.plot()

我已经更新了pandas、matplotlib、numpy、geopandas,但仍然有同样的问题。

~anaconda3libsite-packagesgeopandasgeodataframe.py in plot(self, *args, **kwargs)
919         from there.
920         """
--> 921         return plot_dataframe(self, *args, **kwargs)
922 
923     plot.__doc__ = plot_dataframe.__doc__
~anaconda3libsite-packagesgeopandasplotting.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,
~anaconda3libsite-packagesgeopandasplotting.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)
~anaconda3libsite-packagesgeopandasplotting.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 
~anaconda3libsite-packagespandascorestringsaccessor.py in wrapper(self, *args, **kwargs)
99                 )
100                 raise TypeError(msg)
--> 101             return func(self, *args, **kwargs)
102 
103         wrapper.__name__ = func_name
~anaconda3libsite-packagespandascorestringsaccessor.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版本,然后安装descartes包。

这个问题似乎与笛卡尔/地球标准无关。熊猫1.1.3(在conda环境中(也面临同样的问题,通过更新到1.2.0 解决了这个问题

最新更新