Choropleth贴图不显示

2024-10-01 15:30:59 发布

您现在位置:Python中文网/ 问答频道 /正文

enter image description here

下面的代码未显示所附图像中所示的预期输出。我的代码遗漏了什么

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


Tags: 代码namehttps图像imagedataheredescription
1条回答
网友
1楼 · 发布于 2024-10-01 15:30:59

函数上需要一个右括号。试试这个:

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')

我们无法判断您的代码是否存在任何其他问题,因为我们不知道您的数据帧的形式

相关问题 更多 >

    热门问题