如何使用Folium更正“ValueError:无法渲染任何缺少几何体的对象”

2024-10-05 14:23:13 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经很长时间没有使用堆栈溢出了,所以如果它的格式或位置不正确,我深表歉意

下面的代码是我尝试使用folium和pandas时得到的: “ValueError:无法呈现缺少任何几何图形的对象”

我对python、pandas以及几乎所有API都是相当陌生的。我不明白如何纠正这个错误。现在是凌晨4点,也许我累了,但我想不出来。非常感谢您的帮助

listings = pd.read_csv('clean_listings.csv')
city_wards = pd.read_csv('jersey-city-ward-and-councilperson-map-2018.csv',
                       sep = ';', names = ['Geo Point', 'Ward'], error_bad_lines = False)

listings_map = folium.Map(location = [40.7153535,-74.1387714], 
                     zoom_start = 12)

folium.Marker(
location = [40.719074, -74.050552], 
popup = 'Welcome to Jersey City :)\n',
tooltip = 'Please click for more information',
).add_to(listings_map)

folium.Choropleth(geo_data = city_wards,
              data = mapdata,
              columns = ['neighbourhood', 'latitude', 'longitude'],
              key_on = 'feature.mapdata.neigbourhood',
              fill_color = 'PuRd', fill_opacity = 0.5, line_opacity = 0.2,
              legend_name = 'Wards').add_to(listings_map)

listings_map 

snapshot of my code

snapshot continued

snapshot end


Tags: csvtoaddcitymappandasreaddata