Reputation: 55
I am joining on an online course on Data science (to enriching my own skill set). This is the last project to be handed in for the course
The current request is to make a choropleth map.
This is my code
!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
The error reported is as below
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'
For the record and easy to follow, this is my df1_count dataframe (censored because someone might "steal" this, which means I'm violating the code of the course)
Thank you for your assistance
Upvotes: 0
Views: 1050
Reputation: 499
Try this.
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)
Upvotes: 1