{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
Make this Notebook Trusted to load map: File -> Trust Notebook
" ], "text/plain": [ "" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import folium\n", "import pandas as pd\n", "\n", "\n", "url = (\n", " \"https://raw.githubusercontent.com/python-visualization/folium/master/examples/data\"\n", ")\n", "state_geo = f\"{url}/us-states.json\"\n", "state_unemployment = f\"{url}/US_Unemployment_Oct2012.csv\"\n", "\n", "state_data = pd.read_csv(state_unemployment)\n", "\n", "m = folium.Map(location=[48, -102], zoom_start=3, tiles=\"Stamen Toner\")\n", "\n", "folium.Choropleth(\n", " state_geo,\n", " data=state_data,\n", " columns=[\"State\", \"Unemployment\"],\n", " key_on=\"feature.id\",\n", " fill_color=\"YlGn\",\n", " fill_opacity=0.7,\n", " line_opacity=0.2,\n", " legend_name=\"Unemployment Rate (%)\",\n", ").add_to(m)\n", "\n", "\n", "popup = \"Must be on top of the choropleth\"\n", "\n", "folium.CircleMarker(\n", " location=[48, -102],\n", " radius=10,\n", " fill=True,\n", " popup=popup,\n", " weight=1,\n", ").add_to(m)\n", "\n", "\n", "m" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.0" } }, "nbformat": 4, "nbformat_minor": 1 }