gpt4 book ai didi

python - 无法使用我的代码 : Please guide Thanks 获取 Choropleth Map

转载 作者:行者123 更新时间:2023-12-05 00:39:55 25 4
gpt4 key购买 nike

我收到此错误:choropleth 方法已被弃用。而是使用具有相同参数的新 Choropleth 类。请参阅示例笔记本“GeoJSON_and_choropleth”了解如何执行此操作。

with open('C:/Users/abcdef/Desktop/world_countries.json') as data_file:
data = json.load(data_file)

world_geo = data
world_map = folium.Map(location=[0, 0], zoom_start=2, tiles = 'Mapbox Bright')
world_map.choropleth(
geo_data = world_geo,
data = canadamap,
columns = ['Country', 'Total'],
key_on = 'feature.properties.name',
fill_color = 'YlOrRd',
fill_opacity = 0.7,
line_opacity = 0.2,
legend_name = 'Immigration to Canada'
)

world_map

我没有使用上面的代码获取 Choropleth Map;相反,我得到了

The choropleth method has been deprecated. Instead use the new Choropleth class, which has the same arguments. See the example notebook 'GeoJSON_and_choropleth' for how to do this.

最佳答案

这应该适合你。该方法已修改为 Choropleth 而不是 choropleth。你应该有

folium.Choropleth(args*).add_to(world_map) 

全部

world_geo = r'world_countries.json' # geojson file

# create a plain world map
world_map = folium.Map(location=[0, 0], zoom_start=2, tiles='Mapbox Bright')

# generate choropleth map using the total immigration of each country to Canada from 1980 to 2013
folium.Choropleth(
geo_data=world_geo,
data=df_can,
columns=['Country', 'Total'],
key_on='feature.properties.name',
fill_color='YlOrRd',
fill_opacity=0.7,
line_opacity=0.2,
legend_name='Immigration to Canada'
).add_to(world_map)

# display map

world_map

希望对你有帮助

关于python - 无法使用我的代码 : Please guide Thanks 获取 Choropleth Map,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53971291/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com