首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >​()在Folium0.5.0上获得意外的关键字参数'bins‘bins

​()在Folium0.5.0上获得意外的关键字参数'bins‘bins
EN

Stack Overflow用户
提问于 2020-03-01 22:45:33
回答 1查看 643关注 0票数 0

我正在参加一个关于数据科学的在线课程(以丰富我自己的技能)。这是本课程要交的最后一个项目。

当前的请求是制作一张choropleth地图。

这是我的代码

代码语言:javascript
复制
!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

上报的错误如下

代码语言:javascript
复制
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数据帧(被审查,因为有人可能“窃取”它,这意味着我违反了课程的代码)

感谢您的帮助

EN

回答 1

Stack Overflow用户

发布于 2020-03-01 23:18:21

尝尝这个。

代码语言:javascript
复制
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)
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60476265

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档