将geopandas(世界地图)中的几何图形提取到我的数据帧中

将geopandas(世界地图)中的几何图形提取到我的数据帧中,pandas,dataframe,merge,geopandas,Pandas,Dataframe,Merge,Geopandas,我的数据框有一个国家名称,但没有位置(坐标),所以我试图从geopandas worldmap中提取它。是否有人知道如何从世界地理标记获取几何列,以与my drinks.csv数据框的国家名称匹配,从而在my drinks.csv中创建新列 来自geopandas的世界数据 我的数据集=饮料.csv 我建议您对列值使用索引和切片: # set index of the country shapes to the name of the country country_shapes_newin

我的数据框有一个国家名称,但没有位置(坐标),所以我试图从geopandas worldmap中提取它。是否有人知道如何从世界地理标记获取几何列,以与my drinks.csv数据框的国家名称匹配,从而在my drinks.csv中创建新列

来自geopandas的世界数据

我的数据集=饮料.csv


我建议您对列值使用索引和切片:

# set index of the country shapes to the name of the country
country_shapes_newindex = country_shapes.set_index('name')

# slice on the country shapes using the names of the countries from your drinks dataframe.
# the result is a DataFrame, select the geomtry column, and get their values.
# finally store this in a new column in your drinks DataFrame
drinks['geometry'] = country_shapes_newindex.loc[drinks['Country'].values]['geometry'].values