有人可以在Folium choropleth中解释此代码吗?

时间:2019-06-11 21:36:31

标签: python folium

我正在阅读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)
       }

0 个答案:

没有答案