python - Choropleth 地图不显示
问题描述
我下面的代码没有显示预期的输出,如附图所示。我的代码遗漏了什么?
gjson=r'https://cocl.us/sanfran_geojson'
Sanfransisco=folium.Map(location=[37.77, -122.42], zoom_start=12, tiles='Mapbox Bright')
Sanfransisco.choropleth(
geo_data=gjson,
data=df,
columns=['Neighbourhood','Count'],
key_on='feature.properties.District',
fill_color='YlOrRd',
fill_opacity=0.7,
line_opacity=0.2,
legend_name='Crime rate in Sanfransisco'
文件“”,第 11 行 legend_name='Sanfransisco 的犯罪率' ^ SyntaxError:解析时出现意外 EOF
解决方案
您需要在函数上加上右括号。尝试这个:
Sanfransisco.choropleth(
geo_data=gjson,
data=df,
columns=['Neighbourhood','Count'],
key_on='feature.properties.District',
fill_color='YlOrRd',
fill_opacity=0.7,
line_opacity=0.2,
legend_name='Crime rate in Sanfransisco')
我们无法判断您的代码是否有任何其他问题,因为我们不知道您的 DataFrame 的形式。
推荐阅读
- python - pandas.DataFrame.to_csv 的问题('tuple' 对象没有属性'to_csv')
- c++ - STL 库在不同平台上是否有所不同?
- linux - 如何使用 Gnuplot 在我的 png 周围裁剪顶部和底部边框?
- c# - 具有 TextChange 的文本框相互依赖而没有 StackOverflow 异常
- python - 将 datetime64 数组舍入到最接近的秒数
- pdf - itextsharp - AcroForm 字段值在签署 PDF 文档后消失
- firebase - Firebase 存储仅存储一张图片删除以前上传的图片
- jquery - 单击删除按钮时需要获取行值
- javascript - Gulp 4 - AssertionError [ERR_ASSERTION]:任务从未定义:未定义
- ruby-on-rails - 没有历史的 Rails 重定向