0

尝试保存我的地图时出现以下错误

'KeyError                                  Traceback (most recent call last)
<ipython-input-31-65c9bba51b6f> in <module>()
  7 # Create Folium plot
  8 #map.save('plot_data.html')
----> 9 map.save(outfile= "test.html")
KeyError: 'ATA'

这是我的代码,我在这里尝试绑定 pandas 数据框和 json 几何图形以创建用于数据可视化的叠加层

import folium
import pandas as pd
country_geo  = './world-development-indicators/world-countries.json'
data = pd.read_csv('world-development-indicators/Indicators.csv')
hist_indicator = 'CO2 emissions \(metric'
hist_year = 2011
mask1 = data['IndicatorName'].str.contains(hist_indicator) 
mask2 = data['Year'].isin([hist_year])
stage = data[mask1 & mask2]
plot_data = stage[['CountryCode','Value']]
hist_indicator = stage.iloc[0]['IndicatorName']
map = folium.Map(location=[100, 0], zoom_start=1)
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)
map.save('plot_data.html')
4

0 回答 0