0
votes

I had to resetup my python environment and I get this error message:

AttributeError: 'PandasArray' object has no attribute '_str_startswith'

when I try to use the basic GeoDataFrame.plot() function

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

I already updated pandas, matplotlib, numpy, geopandas and still getting the same issue.

~\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'

Thanks!

2
what are your pandas and geopandas versions? - Lior Cohen
pandas 1.1.5 geopandas 0.8.1 - Galantum

2 Answers

0
votes

Already solved! Had to update pandas to 1.2.0 version and then install the descartes package.

0
votes

The issue seems to be independent of descartes/geopandas. Faced the same issue on pandas 1.1.3 (in a conda environment), solved it by updating to 1.2.0