我正在阅读Folium文档中的这段代码,并且很难理解他们在style_function
中的“功能”中从何处获得了关键的“ id”。
源代码为here。
colorscale = branca.colormap.linear.YlGnBu_09.scale(0, 30)
employed_series = df.set_index('FIPS_Code')['Unemployment_rate_2011']
def style_function(feature):
employed = employed_series.get(int(feature['id'][-5:]), None)
return {
'fillOpacity': 0.5,
'weight': 0,
'fillColor': '#black' if employed is None else colorscale(employed)
}