Skip to content

colors not displaying on choropleth map #913

@loganrudd

Description

@loganrudd

Please add a code sample or a nbviewer link, copy-pastable if possible

import pandas as pd
sf_crime = pd.read_csv('https://cocl.us/sanfran_crime_dataset')
sf_crime.drop(['IncidntNum', 'Category', 'Descript', 'DayOfWeek', 'Date', 'Time', 'Resolution', 'Address', 'X', 'Y', 'Location', 'PdId'], axis=1, inplace=True)
by_zone = sf_crime.apply(pd.Series.value_counts).reset_index()
by_zone.rename(columns={'index':'Neighborhood', 'PdDistrict':'Count'}, inplace=True)

!wget --quiet https://cocl.us/sanfran_geojson -O sf_neighborhoods.json
sf_zones = r'sf_neighborhoods.json'
!pip install folium==0.5.0

sf_lat = 37.77
sf_lon = -122.42
sf_crime_map = folium.Map(location=[sf_lat, sf_lon], 
                         zoom_start=12, 
                         tiles='Mapbox Bright')

sf_crime_map.choropleth(
    geo_data=sf_zones,
    data=by_zone,
    columns=['Neighborhood', 'Count'],
    key_on='feature.properties.name',
    fill_color='YlOrRd', 
    fill_opacity=0.7, 
    line_opacity=0.2,
    legend_name='San Fransisco Crime by Neighborhood'
)

sf_crime_map

Problem description

The above code is used in a Jupyter notebook, and generates a map, but the map doesn't not show the any colors corresponding to the number of crimes in each SF neighborhood.

Expected Output

Output of folium.__version__

A map

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionThe issue contains a question about how to do something

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions