Online Folium Compiler

Code, compile, and run Folium programs online

Python
# Source: https://python-visualization.github.io/folium/latest/getting_started.h
# tml
import pandas
import requests
import folium

state_geo = requests.get(
    "https://raw.githubusercontent.com/python-visualization/folium-example-data/main/us_states.json"
).json()
state_data = pandas.read_csv(
    "https://raw.githubusercontent.com/python-visualization/folium-example-data/main/us_unemployment_oct_2012.csv"
)

map = folium.Map(location=[38, -112], zoom_start=3)

folium.Choropleth(
    geo_data=state_geo,
    name="choropleth",
    data=state_data,
    columns=["State", "Unemployment"],
    key_on="feature.id",
    fill_color="YlGn",
    fill_opacity=0.7,
    line_opacity=0.2,
    legend_name="Unemployment Rate (%)",
).add_to(map)

folium.LayerControl().add_to(map)

map
AI Prompt