I've been working on a map showing crime rate in different San Fransisco Neighbourhoods using Folium Choropleth Maps.
The geojson file I am using is: https://cocl.us/sanfran_geojson and I have saved this as 'data'
And the data I am using is from: https://cocl.us/sanfran_crime_dataset and I have saved this as 'cdata'.
My code is as follows;
cdata.rename(columns={'PdDistrict':'Neighbourhood'}, inplace=True)
neighbourhood = cdata.groupby(['Neighbourhood']).size().reset_index(name='Count')
to obtain:
Neighbourhood Count
0 BAYVIEW 14303
1 CENTRAL 17666
2 INGLESIDE 11594
3 MISSION 19503
4 NORTHERN 20100
5 PARK 8699
6 RICHMOND 8922
7 SOUTHERN 28445
8 TARAVAL 11325
9 TENDERLOIN 9942
Then I use:
sanfran = folium.Map(location=[37.7749, -122.4194], zoom_start = 12)
sanfran.choropleth(
geo_data=dat,
name='choropleth',
data=neighbourhood,
columns=['Neighbourhood', 'Count'],
key_on='properties.DISTRICT',
fill_color='YlOrRd',
fill_opacity = 0.7,
line_opacity=0.2,
legend_name='Crime Rate in San Francisco')
When I run the sanfran.choropleth code, I get the following error:
C:\ProgramData\Anaconda3\lib\site-packages\folium\folium.py:432: FutureWarning: The choropleth method has been deprecated. Instead use the new Choropleth class, which has the same arguments. See the example notebook 'GeoJSON_and_choropleth' for how to do this.
FutureWarning
And then if i just type 'sanfran' and run the code I get:
unhashable type: 'list'
Would really appreciate some help with this, thank you!