2017-09-08 1 views
0

Ich lese Alexander T. Combs ‚s Buch- Python Machine Learning Blueprints: Intuitive data projects you can relate to.folium 0,4 kann nicht funktionieren: Typeerror: choropleth() bekam ein unerwartetes Stichwort Argument 'geo_path'

Es gibt einige Fragen auf ch2.The Code auf dem Buch :

map = folium.Map(location=[40.748817, -73.985428], zoom_start=13) 
map.geo_json(geo_path=r'/Users/alexcombs/Downloads/nyc.json', data=su_lt_two, 
      columns=['Zip', 'Rent'], 
      key_on='feature.properties.postalCode', 
      threshold_scale=[1700.00, 1900.00, 2100.00, 2300.00, 2500.00, 2750.00], 
      fill_color='YlOrRd', fill_opacity=0.7, line_opacity=0.2, 
      legend_name='Rent (%)', 
       reset=True) 
map.create_map(path='nyc.html') 

Mein Code:

map = folium.Map(location=[40.748817, -73.985428], zoom_start=13) 

nyc = r'nyc.json' 

map.choropleth(geo_path = nyc, data=su_lt_two,columns=['zip', 'Rent'], 
       key_on='Feature.properties.postalCode', 
       threshold_scale=[1700.00, 1900.00, 2100.00, 2300.00, 2500.00, 2750.00], 
       fill_color='YlOrRd', fill_opacity=0.7, line_opacity=0.2, 
       legend_name='Rent (%)',reset=True) 

map.create_map(path='nyc.html') 

und ich bekam Typeerror:

--------------------------------------------------------------------------- 
TypeError         Traceback (most recent call last) 
<ipython-input-129-420abe6d80fb> in <module>() 
     8    threshold_scale=[1700.00, 1900.00, 2100.00, 2300.00, 2500.00, 2750.00], 
     9    fill_color='YlOrRd', fill_opacity=0.7, line_opacity=0.2, 
---> 10    legend_name='Rent (%)',reset=True) 
    11 
    12 map.create_map(path='nyc.html') 

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

nyc.json file

Antwort

1

Es gab einige api changes mit 0,4.

Hier ist die eine, die

  • choropleth now takes a single geo_data instad of geo_path/geo_str leaving the parsing to GeoJSON

Versuchen Sie, diese

map.choropleth(geo_data = nyc, data=su_lt_two,columns=['zip', 'Rent'], 
       key_on='Feature.properties.postalCode', 
       threshold_scale=[1700.00, 1900.00, 2100.00, 2300.00, 2500.00, 2750.00], 
       fill_color='YlOrRd', fill_opacity=0.7, line_opacity=0.2, 
       legend_name='Rent (%)',reset=True) 
Ihre Fehler verursacht
Verwandte Themen