我正在参加一个关于数据科学的在线课程(以丰富我自己的技能)。这是本课程要交的最后一个项目。
当前的请求是制作一张choropleth地图。
这是我的代码
!conda install -c conda-forge folium=0.5.0 --yes
import folium
!wget --quiet https://ibm.box.com/shared/static/cto2qv7nx6yq19logfcissyy4euo8lho.json
-O world_countries.json sfgeo=r'world_countries.json'
sfmap=folium.Map(location=[37.77986,-122.42905],zoom_start=12)
threshold_scale = np.linspace(df1_count['Count'].min(), df1_count['Count'].max(), 6, dtype=int)
threshold_scale = threshold_scale.tolist()
sfmap.choropleth(geo_data=sfgeo,
data=df1_count,
columns=['PdDistrict','Count'],
bins = threshold_scale,
key_on='feature.properties.name',
fill_color = 'YlOrRd',
fill_opacity = 0.7,
line_opacity=0.2,
legend_name='Rate'
)
sfmap上报的错误如下
TypeError Traceback (most recent call last)
<ipython-input-75-1f74ef523c22> in <module>
13 fill_opacity = 0.7,
14 line_opacity=0.2,
---> 15 legend_name='Rate'
16 )
17
TypeError: choropleth() got an unexpected keyword argument 'bins'为了记录和容易理解,这是我的df1_count数据帧(被审查,因为有人可能“窃取”它,这意味着我违反了课程的代码)

感谢您的帮助
发布于 2020-03-01 23:18:21
尝尝这个。
folium.Choropleth(geo_data=sfgeo,
data=df1_count,
columns=['PdDistrict','Count'],
bins = threshold_scale,
key_on='feature.properties.name',
fill_color = 'YlOrRd',
fill_opacity = 0.7,
line_opacity=0.2,
legend_name='Rate'
).add_to(sfmap)https://stackoverflow.com/questions/60476265
复制相似问题