Skip to content

an unexpected error with the 'shapefile' #3

@tomaszek0

Description

@tomaszek0

I have encountered an error while trying to load a shapefile with world coordinates "ne_110m_admin_0_countries.shp" and the corresponding .shx (v5.1.1). I followed the code in your 'obesity.ipnyb' file, which included the following code:

import geopandas as gpd
shapefile = 'countries_110m/ne_110m_admin_0_countries.shp'
gdf = gpd.read_file(shapefile)[['ADMIN', 'ADM0_A3', 'geometry']]

However, when I executed this code, I received the following error: "KeyError: "['ADMIN', 'ADM0_A3'] not in index".
I also tried loading shapefile v4.0.1, but encountered the same error.
When I loaded the file using the following code, it only contained the 'geometry' column:

gdf = gpd.read_file(shapefile)
gdf.head()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions