首页 > 解决方案 > 在 GeoPandas 中创建数据框会给出“TypeError super(type, obj): obj must be an instance or subtype of type”

问题描述

TypeError: super(type, obj): obj must be an instance or subtype of type为 2 列 lat 和 long 的点创建 1 列时

你能帮我解决这个问题吗?

我有一个数据集 customer_lat, customer_lng 我想从 lat long 创建 1 列作为一个点

from shapely.geometry import Polygon
from shapely.geometry import Point
import pandas as pd
import geopandas as gpd
df=pd.read_csv("C:\\Users\\n.nguyen.2\\Documents\\order from May 1.csv")

geometry=[Point(xy) for xy in zip(df['customer_lat'],df['customer_lng'])]
crs={'init':'epsg:4326'}
gdf=gpd.GeoDataFrame(df,crs=crs,geometry=geometry)
gdf.head()
Traceback (most recent call last):

  File "<ipython-input-82-1f38d31ae996>", line 9, in <module>
    gdf=gpd.GeoDataFrame(df,crs=crs,geometry=geometry)

  File "C:\Users\n.nguyen.2\AppData\Local\Continuum\anaconda3\lib\site-packages\geopandas\geodataframe.py", line 47, in __init__
    super(GeoDataFrame, self).__init__(*args, **kwargs)

TypeError: super(type, obj): obj must be an instance or subtype of type

标签: pythonpandasdataframegeopandasshapely

解决方案


推荐阅读