Python 3.x 如何使用sjoin合并两个GeodataFrame而不出错

Python 3.x 如何使用sjoin合并两个GeodataFrame而不出错,python-3.x,geopandas,Python 3.x,Geopandas,我试图完成两个GeodataFrame之间的空间连接,但出现以下错误: ValueError: You are trying to merge on object and int64 columns. If you wish to proceed you should use pd.concat. 这是我的代码/计划,导致了我的错误 这两个数据帧分别命名为tag_df和cpr_df,其中包含纬度和经度值,因此我首先为这两个数据帧创建了一个地理数据帧 tag_df['coordinates']=

我试图完成两个GeodataFrame之间的空间连接,但出现以下错误:

ValueError: You are trying to merge on object and int64 columns. If you wish to proceed you should use pd.concat.
这是我的代码/计划,导致了我的错误

这两个数据帧分别命名为
tag_df
cpr_df
,其中包含纬度和经度值,因此我首先为这两个数据帧创建了一个地理数据帧

tag_df['coordinates']=list(zip(tag_df.Longitude,tag_df.Latitude))
tag_df['coordinates']=tag_df['coordinates'].apply(Point)
tag_gdf=gpd.GeoDataFrame(tag_df,geometry='coordinates',crs={'init' :'epsg:4326'})

cpr_df['coordinates']=list(zip(cpr_df.sample_longitude_decimal,cpr_df.sample_latitude_decimal))
cpr_df['coordinates']=cpr_df['coordinates'].apply(Point)
cpr_gdf=gpd.GeoDataFrame(cpr_df,geometry='coordinates',crs={'init' :'epsg:4326'})
然后我为cpr\U gdf创建了一个5海里的缓冲区:

cpr_gdf['p_buffer']=cpr_gdf['coordinates'].buffer(5*(1/60))
我现在想做一个空间连接,找出哪些
tag\u gdf
值是缓冲
cpr\u gdf

tag_in_cpr=sjoin(tag_gdf,cpr_gdf,how='left',op='within')
这就产生了这个错误:

ValueError: You are trying to merge on object and int64 columns. If you wish to proceed you should use pd.concat

任何帮助都会很好。

解决方案(目前)是将您的pandas版本从0.23降级到0.22。不幸的是,该错误是由pandas 0.23.0中的更改引起的。但是,鉴于此处的错误报告:,该错误可能还掩盖了没有行实际匹配的问题。在我使用how='inner'获得一个空的GeoDataFrame之后,您可以使用
how='inner'
Hi来检查是否存在这种情况。然而,根据对文件的了解,我知道在cpr_gdf中有tag_gdf值。我看到了你对链接的修复,但我不确定如何将其输入到我的代码中?你确定它们重叠吗?(例如你绘制了它们吗?)一个原因可能是两者都有不同的坐标参考系,geopandas不会自动将它们转换为相同的坐标系。如果
how='internal'
给出了一个空帧,这意味着没有重叠,我提到的修复不会改变这一点。您好,我很抱歉geopandas 0.22确实有效,谢谢您。。但是现在右边的df(cpr_gdf)具有所有的nan值。