TransWikia.com

Python: Cannot construct empty GeoDataFrame with columns

Geographic Information Systems Asked on April 24, 2021

My script

import geopandas as gp
test = gp.GeoDataFrame(columns=['geometry', 'costs'])

the error:

File "/usr/local/lib/python3.7/dist-packages/geopandas/geodataframe.py", line 89, in__init__ super(GeoDataFrame, self).__init__(*args, **kwargs)
file "/usr/lib/python3/dist-packages/pandas/core/frame.py", line 348, in __init__ 
mgr = self._init_dict(data, index, columns, dtype=dtype)
File "/usr/lib/python3/dist-packages/pandas/core/frame.py", line 451, in _init_dict                                                                                                                      nan_dtype)
File "/usr/lib/python3/dist-packages/pandas/core/dtypes/cast.py", line 1196, in construct_1d_arraylike_from_scalar
dtype = dtype.dtype
AttributeError: type object 'object' has no attribute 'dtype'  

What could be the reason for that? It always worked for me like that. Now I had a software update and it suddenly does not work anymore.

One Answer

Had the wrong pandas version.

pip3 install pandas == 1.2.2

fixed it for me

Answered by Leo on April 24, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP