Search code examples
python-3.xvisualizationchoroplethfolium

Folium library error in choropleth


Am using folium library with an open data set from kaggle,

map.choropleth(geo_path=country_geo, data=plot_data,
         columns=['CountryCode', 'Value'],
         key_on='feature.id',
         fill_color='YlGnBu', fill_opacity=0.7, line_opacity=0.2,
         legend_name=hist_indicator
          )

The above part of the code is giving me the following error:

TypeError: choropleth() got an unexpected keyword argument 'geo_path'

When I replace geo_path with geo_data I get this error:

 JSONDecodeError: Expecting value: line 7 column 1 (char 6)

Solution

  • Is the issue related to "UCSanDiegoX: DSE200x Python for Data Science"? I took the advice of Cody and rename geo_path to geo_data at the specifications of map.choropleth. At the git hub repository, take care of using the RAW data, which is in fact a file structured with the format GeoJSON. The first two lines should start like the code provided below

    {"type":"FeatureCollection","features":[
    {"type":"Feature","properties":{"name":"Afghanistan"},"geometry":
    {"type":"Polygon","coordinates":[[[61.210817,35.650072],.....