From b509b4a6cbb712248e96c89d442c37412cdbec5c Mon Sep 17 00:00:00 2001 From: Sarthak Khanna Date: Mon, 7 Oct 2024 16:14:51 +0200 Subject: [PATCH] Update geopandas example to support versions >=1.0 (fixes issue #4778) --- doc/python/scatter-plots-on-maps.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/doc/python/scatter-plots-on-maps.md b/doc/python/scatter-plots-on-maps.md index 9c4ad70bea8..e6e0d8546dc 100644 --- a/doc/python/scatter-plots-on-maps.md +++ b/doc/python/scatter-plots-on-maps.md @@ -74,13 +74,17 @@ fig.show() import plotly.express as px import geopandas as gpd -geo_df = gpd.read_file(gpd.datasets.get_path('naturalearth_cities')) +if gpd.__version__ < '1.0': + geo_df = gpd.read_file(gpd.datasets.get_path('naturalearth_cities')) +else: + import geodatasets + geo_df = gpd.read_file(geodatasets.get_path('naturalearth_cities')) px.set_mapbox_access_token(open(".mapbox_token").read()) fig = px.scatter_geo(geo_df, - lat=geo_df.geometry.y, - lon=geo_df.geometry.x, - hover_name="name") + lat=geo_df.geometry.y, + lon=geo_df.geometry.x, + hover_name="name") fig.show() ```