2017-10-12 62 views
0

現在用大青葉庫,大青葉庫錯誤與開放的數據從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 
     ) 

代碼的上面部分是給我下面的錯誤:

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

當我更換geo_pathgeo_data我得到這個錯誤:

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

回答

0

geo_path沒有按」 t工作,因爲它不是一個choropleth參數。你用geo_data替換它是正確的。

您的第二個錯誤可能是由於格式不正確或格式不正確的geojson文件造成的。

http://python-visualization.github.io/folium/docs-master/modules.html?highlight=chor#您的geo_data參數需要爲您的GeoJSON幾何體的「URL,文件路徑或數據(json,dict,geopandas等)」。

以GeoJSON格式的文件,按照這個結構從geojson.org:

{ 
    "type": "Feature", 
    "geometry": { 
    "type": "Point", 
    "coordinates": [125.6, 10.1] 
    }, 
    "properties": { 
    "name": "Dinagat Islands" 
    } 
} 
0

是與 「UCSanDiegoX:DSE200x的Python數據科學」 的問題?我接受了Cody的建議,並將geo_path重命名爲geo_data,格式爲map.choropleth。 在git hub資源庫中,請注意使用RAW數據,它實際上是一個格式爲GeoJSON的文件。前兩行應該像下面提供的代碼一樣開始

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