我实际上试图显示一个未显示的Choropleth映射位,仅显示带有图例名称的灰色空间...我什至检查了key_on
参数。
我什至尝试将其另存为HTML文件并在Microsoft Edge中打开它,但它无法正常工作。
import pandas as pd
import matplotlib as mpl
import matplotlib.pyplot as plt
import wget
df_c=pd.read_csv('Police_department_Incidents.csv')
df_crime=df_c.groupby('PdDistrict',axis=0)['PdDistrict'].count()
df_crime=df_crime.to_frame()
df_crime.columns=['0']
df_crime.reset_index(inplace=True)
df_crime.columns=['Neighborhood','Count']
df_crime
print('Beginning file download with wget module')
url='https://cocl.us/sanfran_geojson'
wget.download(url,'c:/Users/pj/san_fran.json')
loc_json=r'san_fran.json'
crime_map=folium.Map(location=[-122.431297,37.773972]
,zoom_start=12,tiles='Mapbox Bright')
crime_map.choropleth(geo_data=loc_json,
data=df_crime,
columns=['Neighborhood','Count'],
key_on='feature.properties.DISTRICT',
fill_color='YlOrRd',
fill_opacity=0.7,
line_opacity=0.2,
legend_name='Crime Rate in San Fransico')
crime_map