I'm trying to show happiness levels based on the country using folium choropleth, however, it doesn't work and all countries are just grey. This is what I get:
json file: https://github.com/python-visualization/folium/blob/master/examples/data/world-countries.json
csv file: https://drive.google.com/file/d/1aI5tILdPYyx0yjbgPPZcJHEqxbZ4oPBg/view?usp=sharing
and this is my code:
import folium
import pandas as pd
country_geo = 'world-countries.json'
country_data = pd.read_csv('Happiness_Dataset_2016.csv')
bins = list(country_data['Happiness Score'].quantile([0, 0.25, 0.5, 0.75, 1]))
m = folium.Map(location=[0,0], zoom_start=2)
folium.Choropleth(
geo_data=country_geo,
name='choropleth',
data=country_data,
columns=['Country','Happiness Score'],
Key_on='feature.properties.name',
fill_color='BuPu',
fill_opacity=0.2,
line_opacity=0.5,
legend_name='Happiness Rates (%)',
bins =bins,
reset=True
).add_to(m)
# folium.LayerControl().add_to(m)
m
m.save('worldmap.html')