副舞蹈题

问题描述 投票:0回答:1

我在某处出现错误,但无法解决。希望能得到一些反馈。谢谢。

df_grp:

   Neighborhood  Count
0   BAYVIEW      14303
1   CENTRAL      17666
2   INGLESIDE    11594
3   MISSION      19503
4   NORTHERN     20100
5   PARK          8699
6   RICHMOND      8922
7   SOUTHERN     28445
8   TARAVAL      11325
9   TENDERLOIN    9942

代码:

!wget --quiet https://cocl.us/sanfran_geojson -O san_fran.json
sf_geo = r'san_fran.json'
m = folium.Map(location=[37.773972, -122.431297], zoom_start=12)

m.choropleth(
    geo_data=sf_geo,
    data=df_grp,
    columns=['Neighborhood', 'Count'],
    key_on='feature.properties.name',
    fill_color='YlOrRd', 
    fill_opacity=0.7, 
    line_opacity=0.2,
    legend_name='San Francisco Crime by Neighborhood'
)

m

enter image description here

python python-3.x pandas folium choropleth
1个回答
1
投票

错误出在:

key_on='feature.properties.name',

将其更改为:

key_on='feature.properties.DISTRICT',

您得到:

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.