Last active
December 15, 2023 19:50
-
-
Save georgesb/eb9dd09f4419903137a0e5cbe476005c to your computer and use it in GitHub Desktop.
MedianIncome.ipynb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"nbformat": 4, | |
"nbformat_minor": 0, | |
"metadata": { | |
"colab": { | |
"provenance": [], | |
"authorship_tag": "ABX9TyP/4nnHQwKLPFGreOKx3TDu", | |
"include_colab_link": true | |
}, | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3" | |
}, | |
"language_info": { | |
"name": "python" | |
} | |
}, | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "view-in-github", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"<a href=\"https://colab.research.google.com/gist/georgesb/eb9dd09f4419903137a0e5cbe476005c/medianincome.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/", | |
"height": 592 | |
}, | |
"id": "TAJ7FCrT-nyT", | |
"outputId": "975c6099-3b23-4ddd-adab-ce4fdfe6247b" | |
}, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"text/plain": [ | |
"<folium.folium.Map at 0x7aa8d54f7760>" | |
], | |
"text/html": [ | |
"<div style=\"width:100%;\"><div style=\"position:relative;width:100%;height:0;padding-bottom:60%;\"><span style=\"color:#565656\">Make this Notebook Trusted to load map: File -> Trust Notebook</span><iframe srcdoc=\"<!DOCTYPE html>\n", | |
"<html>\n", | |
"<head>\n", | |
" \n", | |
" <meta http-equiv="content-type" content="text/html; charset=UTF-8" />\n", | |
" \n", | |
" <script>\n", | |
" L_NO_TOUCH = false;\n", | |
" L_DISABLE_3D = false;\n", | |
" </script>\n", | |
" \n", | |
" <style>html, body {width: 100%;height: 100%;margin: 0;padding: 0;}</style>\n", | |
" <style>#map {position:absolute;top:0;bottom:0;right:0;left:0;}</style>\n", | |
" <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/leaflet.js"></script>\n", | |
" <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>\n", | |
" <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>\n", | |
" <script src="https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.js"></script>\n", | |
" <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/leaflet.css"/>\n", | |
" <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"/>\n", | |
" <link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css"/>\n", | |
" <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/[email protected]/css/all.min.css"/>\n", | |
" <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css"/>\n", | |
" <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/python-visualization/folium/folium/templates/leaflet.awesome.rotate.min.css"/>\n", | |
" \n", | |
" <meta name="viewport" content="width=device-width,\n", | |
" initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />\n", | |
" <style>\n", | |
" #map_4c77671e29448fd2f401b34d4ce4f78c {\n", | |
" position: relative;\n", | |
" width: 100.0%;\n", | |
" height: 100.0%;\n", | |
" left: 0.0%;\n", | |
" top: 0.0%;\n", | |
" }\n", | |
" .leaflet-container { font-size: 1rem; }\n", | |
" </style>\n", | |
" \n", | |
"</head>\n", | |
"<body>\n", | |
" \n", | |
" \n", | |
" <div class="folium-map" id="map_4c77671e29448fd2f401b34d4ce4f78c" ></div>\n", | |
" \n", | |
"</body>\n", | |
"<script>\n", | |
" \n", | |
" \n", | |
" var map_4c77671e29448fd2f401b34d4ce4f78c = L.map(\n", | |
" "map_4c77671e29448fd2f401b34d4ce4f78c",\n", | |
" {\n", | |
" center: [37.0902, -95.7129],\n", | |
" crs: L.CRS.EPSG3857,\n", | |
" zoom: 4.5,\n", | |
" zoomControl: true,\n", | |
" preferCanvas: false,\n", | |
" }\n", | |
" );\n", | |
"\n", | |
" \n", | |
"\n", | |
" \n", | |
" \n", | |
" var tile_layer_4dbc8e503906ecb8f46eddb640fc82e1 = L.tileLayer(\n", | |
" "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",\n", | |
" {"attribution": "Data by \\u0026copy; \\u003ca target=\\"_blank\\" href=\\"http://openstreetmap.org\\"\\u003eOpenStreetMap\\u003c/a\\u003e, under \\u003ca target=\\"_blank\\" href=\\"http://www.openstreetmap.org/copyright\\"\\u003eODbL\\u003c/a\\u003e.", "detectRetina": false, "maxNativeZoom": 18, "maxZoom": 18, "minZoom": 0, "noWrap": false, "opacity": 1, "subdomains": "abc", "tms": false}\n", | |
" ).addTo(map_4c77671e29448fd2f401b34d4ce4f78c);\n", | |
" \n", | |
" \n", | |
" var marker_4a19e69bdb6c97aed1d4af7e185bd38d = L.marker(\n", | |
" [36.17, -119.7462],\n", | |
" {}\n", | |
" ).addTo(map_4c77671e29448fd2f401b34d4ce4f78c);\n", | |
" \n", | |
" \n", | |
" var icon_1970e4f324422f782f9d130ec3cc2e03 = L.AwesomeMarkers.icon(\n", | |
" {"extraClasses": "fa-rotate-0", "icon": "info-sign", "iconColor": "white", "markerColor": "blue", "prefix": "glyphicon"}\n", | |
" );\n", | |
" marker_4a19e69bdb6c97aed1d4af7e185bd38d.setIcon(icon_1970e4f324422f782f9d130ec3cc2e03);\n", | |
" \n", | |
" \n", | |
" var popup_26c38ad1099564b9a269cbf620eb69dd = L.popup({"maxWidth": "100%"});\n", | |
"\n", | |
" \n", | |
" \n", | |
" var html_4fb3b3d6444c0e395f449624e0a740ed = $(`<div id="html_4fb3b3d6444c0e395f449624e0a740ed" style="width: 100.0%; height: 100.0%;">California $80,423</div>`)[0];\n", | |
" popup_26c38ad1099564b9a269cbf620eb69dd.setContent(html_4fb3b3d6444c0e395f449624e0a740ed);\n", | |
" \n", | |
" \n", | |
"\n", | |
" marker_4a19e69bdb6c97aed1d4af7e185bd38d.bindPopup(popup_26c38ad1099564b9a269cbf620eb69dd)\n", | |
" ;\n", | |
"\n", | |
" \n", | |
" \n", | |
" \n", | |
" var marker_74acf4c832d30cfee401bca2e3645c6d = L.marker(\n", | |
" [42.1497, -74.9384],\n", | |
" {}\n", | |
" ).addTo(map_4c77671e29448fd2f401b34d4ce4f78c);\n", | |
" \n", | |
" \n", | |
" var icon_e8fd03c87c91142907c49fc9d80bd2e6 = L.AwesomeMarkers.icon(\n", | |
" {"extraClasses": "fa-rotate-0", "icon": "info-sign", "iconColor": "white", "markerColor": "blue", "prefix": "glyphicon"}\n", | |
" );\n", | |
" marker_74acf4c832d30cfee401bca2e3645c6d.setIcon(icon_e8fd03c87c91142907c49fc9d80bd2e6);\n", | |
" \n", | |
" \n", | |
" var popup_e82c3c83a919c089654ac27e726f14bc = L.popup({"maxWidth": "100%"});\n", | |
"\n", | |
" \n", | |
" \n", | |
" var html_582acb4778e2e6ac45e9b070e71954d2 = $(`<div id="html_582acb4778e2e6ac45e9b070e71954d2" style="width: 100.0%; height: 100.0%;">New York $72,038</div>`)[0];\n", | |
" popup_e82c3c83a919c089654ac27e726f14bc.setContent(html_582acb4778e2e6ac45e9b070e71954d2);\n", | |
" \n", | |
" \n", | |
"\n", | |
" marker_74acf4c832d30cfee401bca2e3645c6d.bindPopup(popup_e82c3c83a919c089654ac27e726f14bc)\n", | |
" ;\n", | |
"\n", | |
" \n", | |
" \n", | |
" \n", | |
" var marker_0d6744f0f0db00cf8127afc1edef890b = L.marker(\n", | |
" [40.3363, -89.0022],\n", | |
" {}\n", | |
" ).addTo(map_4c77671e29448fd2f401b34d4ce4f78c);\n", | |
" \n", | |
" \n", | |
" var icon_4741c86834e1026eb3ba9c9a02d85b53 = L.AwesomeMarkers.icon(\n", | |
" {"extraClasses": "fa-rotate-0", "icon": "info-sign", "iconColor": "white", "markerColor": "blue", "prefix": "glyphicon"}\n", | |
" );\n", | |
" marker_0d6744f0f0db00cf8127afc1edef890b.setIcon(icon_4741c86834e1026eb3ba9c9a02d85b53);\n", | |
" \n", | |
" \n", | |
" var popup_005d6b629894c4daba971aaedc9cf6b8 = L.popup({"maxWidth": "100%"});\n", | |
"\n", | |
" \n", | |
" \n", | |
" var html_03f0bdbe9c9523395c56644b0fde8ac3 = $(`<div id="html_03f0bdbe9c9523395c56644b0fde8ac3" style="width: 100.0%; height: 100.0%;">Illinois $69,212</div>`)[0];\n", | |
" popup_005d6b629894c4daba971aaedc9cf6b8.setContent(html_03f0bdbe9c9523395c56644b0fde8ac3);\n", | |
" \n", | |
" \n", | |
"\n", | |
" marker_0d6744f0f0db00cf8127afc1edef890b.bindPopup(popup_005d6b629894c4daba971aaedc9cf6b8)\n", | |
" ;\n", | |
"\n", | |
" \n", | |
" \n", | |
" \n", | |
" var marker_f0038adf5597505016d2b0c6197baea8 = L.marker(\n", | |
" [31.106, -97.6475],\n", | |
" {}\n", | |
" ).addTo(map_4c77671e29448fd2f401b34d4ce4f78c);\n", | |
" \n", | |
" \n", | |
" var icon_101c63b0a6c253e2598fcb9698fc1f3d = L.AwesomeMarkers.icon(\n", | |
" {"extraClasses": "fa-rotate-0", "icon": "info-sign", "iconColor": "white", "markerColor": "blue", "prefix": "glyphicon"}\n", | |
" );\n", | |
" marker_f0038adf5597505016d2b0c6197baea8.setIcon(icon_101c63b0a6c253e2598fcb9698fc1f3d);\n", | |
" \n", | |
" \n", | |
" var popup_a86bbc5903dd61c949e72884b2afd57f = L.popup({"maxWidth": "100%"});\n", | |
"\n", | |
" \n", | |
" \n", | |
" var html_7f3038f05349171369129bea39ad92f7 = $(`<div id="html_7f3038f05349171369129bea39ad92f7" style="width: 100.0%; height: 100.0%;">Texas $64,044</div>`)[0];\n", | |
" popup_a86bbc5903dd61c949e72884b2afd57f.setContent(html_7f3038f05349171369129bea39ad92f7);\n", | |
" \n", | |
" \n", | |
"\n", | |
" marker_f0038adf5597505016d2b0c6197baea8.bindPopup(popup_a86bbc5903dd61c949e72884b2afd57f)\n", | |
" ;\n", | |
"\n", | |
" \n", | |
" \n", | |
" \n", | |
" var marker_73f45a4d69728d5409f189cb4b9a1a6f = L.marker(\n", | |
" [47.3917, -121.5708],\n", | |
" {}\n", | |
" ).addTo(map_4c77671e29448fd2f401b34d4ce4f78c);\n", | |
" \n", | |
" \n", | |
" var icon_7c80f3e496653e8e0bb11e40b594d995 = L.AwesomeMarkers.icon(\n", | |
" {"extraClasses": "fa-rotate-0", "icon": "info-sign", "iconColor": "white", "markerColor": "blue", "prefix": "glyphicon"}\n", | |
" );\n", | |
" marker_73f45a4d69728d5409f189cb4b9a1a6f.setIcon(icon_7c80f3e496653e8e0bb11e40b594d995);\n", | |
" \n", | |
" \n", | |
" var popup_d9e6113cba41fc4d195f24cc6817c514 = L.popup({"maxWidth": "100%"});\n", | |
"\n", | |
" \n", | |
" \n", | |
" var html_af49b6016f60002526f54824b6027685 = $(`<div id="html_af49b6016f60002526f54824b6027685" style="width: 100.0%; height: 100.0%;">Washington $78,674</div>`)[0];\n", | |
" popup_d9e6113cba41fc4d195f24cc6817c514.setContent(html_af49b6016f60002526f54824b6027685);\n", | |
" \n", | |
" \n", | |
"\n", | |
" marker_73f45a4d69728d5409f189cb4b9a1a6f.bindPopup(popup_d9e6113cba41fc4d195f24cc6817c514)\n", | |
" ;\n", | |
"\n", | |
" \n", | |
" \n", | |
" \n", | |
" var marker_b0384fc8f829174a49f19bb4acf72c6c = L.marker(\n", | |
" [42.0046, -93.214],\n", | |
" {}\n", | |
" ).addTo(map_4c77671e29448fd2f401b34d4ce4f78c);\n", | |
" \n", | |
" \n", | |
" var icon_bbe83208f2d8f6b0d4a8537388835892 = L.AwesomeMarkers.icon(\n", | |
" {"extraClasses": "fa-rotate-0", "icon": "info-sign", "iconColor": "white", "markerColor": "blue", "prefix": "glyphicon"}\n", | |
" );\n", | |
" marker_b0384fc8f829174a49f19bb4acf72c6c.setIcon(icon_bbe83208f2d8f6b0d4a8537388835892);\n", | |
" \n", | |
" \n", | |
" var popup_268e735b9f3238eb818aa2ba18a3d7a5 = L.popup({"maxWidth": "100%"});\n", | |
"\n", | |
" \n", | |
" \n", | |
" var html_d985ef38486ad75623088dbd022a5efe = $(`<div id="html_d985ef38486ad75623088dbd022a5efe" style="width: 100.0%; height: 100.0%;">Iowa $61,807</div>`)[0];\n", | |
" popup_268e735b9f3238eb818aa2ba18a3d7a5.setContent(html_d985ef38486ad75623088dbd022a5efe);\n", | |
" \n", | |
" \n", | |
"\n", | |
" marker_b0384fc8f829174a49f19bb4acf72c6c.bindPopup(popup_268e735b9f3238eb818aa2ba18a3d7a5)\n", | |
" ;\n", | |
"\n", | |
" \n", | |
" \n", | |
" \n", | |
" var marker_ed01dbfec40159c9de15688c3cfaee64 = L.marker(\n", | |
" [27.8333, -81.717],\n", | |
" {}\n", | |
" ).addTo(map_4c77671e29448fd2f401b34d4ce4f78c);\n", | |
" \n", | |
" \n", | |
" var icon_4cf697b06ec13bbf838f300bf0443553 = L.AwesomeMarkers.icon(\n", | |
" {"extraClasses": "fa-rotate-0", "icon": "info-sign", "iconColor": "white", "markerColor": "blue", "prefix": "glyphicon"}\n", | |
" );\n", | |
" marker_ed01dbfec40159c9de15688c3cfaee64.setIcon(icon_4cf697b06ec13bbf838f300bf0443553);\n", | |
" \n", | |
" \n", | |
" var popup_41d402292cb4a55bf63c013953ed02bf = L.popup({"maxWidth": "100%"});\n", | |
"\n", | |
" \n", | |
" \n", | |
" var html_de6ad31826f4cae46d43420a1d6afc6f = $(`<div id="html_de6ad31826f4cae46d43420a1d6afc6f" style="width: 100.0%; height: 100.0%;">Florida $90,395</div>`)[0];\n", | |
" popup_41d402292cb4a55bf63c013953ed02bf.setContent(html_de6ad31826f4cae46d43420a1d6afc6f);\n", | |
" \n", | |
" \n", | |
"\n", | |
" marker_ed01dbfec40159c9de15688c3cfaee64.bindPopup(popup_41d402292cb4a55bf63c013953ed02bf)\n", | |
" ;\n", | |
"\n", | |
" \n", | |
" \n", | |
" \n", | |
" var marker_3c5be3b0bc69248aca0748d55880e54a = L.marker(\n", | |
" [38.4199, -117.1219],\n", | |
" {}\n", | |
" ).addTo(map_4c77671e29448fd2f401b34d4ce4f78c);\n", | |
" \n", | |
" \n", | |
" var icon_50d245c8790e8ae2e35a9d6aee344f52 = L.AwesomeMarkers.icon(\n", | |
" {"extraClasses": "fa-rotate-0", "icon": "info-sign", "iconColor": "white", "markerColor": "blue", "prefix": "glyphicon"}\n", | |
" );\n", | |
" marker_3c5be3b0bc69248aca0748d55880e54a.setIcon(icon_50d245c8790e8ae2e35a9d6aee344f52);\n", | |
" \n", | |
" \n", | |
" var popup_5ba68eb29c3046d6f4200f93135b5c4f = L.popup({"maxWidth": "100%"});\n", | |
"\n", | |
" \n", | |
" \n", | |
" var html_ddb750d3b287f8af627e8826e799bdee = $(`<div id="html_ddb750d3b287f8af627e8826e799bdee" style="width: 100.0%; height: 100.0%;">Nevada $63,268</div>`)[0];\n", | |
" popup_5ba68eb29c3046d6f4200f93135b5c4f.setContent(html_ddb750d3b287f8af627e8826e799bdee);\n", | |
" \n", | |
" \n", | |
"\n", | |
" marker_3c5be3b0bc69248aca0748d55880e54a.bindPopup(popup_5ba68eb29c3046d6f4200f93135b5c4f)\n", | |
" ;\n", | |
"\n", | |
" \n", | |
" \n", | |
" \n", | |
" var marker_7f750be5ca313b7e9944ad7c231fa717 = L.marker(\n", | |
" [32.7673, -89.6812],\n", | |
" {}\n", | |
" ).addTo(map_4c77671e29448fd2f401b34d4ce4f78c);\n", | |
" \n", | |
" \n", | |
" var icon_2cc28e1280730f4d04f0ce537055040a = L.AwesomeMarkers.icon(\n", | |
" {"extraClasses": "fa-rotate-0", "icon": "info-sign", "iconColor": "white", "markerColor": "blue", "prefix": "glyphicon"}\n", | |
" );\n", | |
" marker_7f750be5ca313b7e9944ad7c231fa717.setIcon(icon_2cc28e1280730f4d04f0ce537055040a);\n", | |
" \n", | |
" \n", | |
" var popup_515f7dc4194ea4a6f65d99797094482f = L.popup({"maxWidth": "100%"});\n", | |
"\n", | |
" \n", | |
" \n", | |
" var html_b386e1c92e07a4f82841813e1f3ffab3 = $(`<div id="html_b386e1c92e07a4f82841813e1f3ffab3" style="width: 100.0%; height: 100.0%;">Mississippi $45,928</div>`)[0];\n", | |
" popup_515f7dc4194ea4a6f65d99797094482f.setContent(html_b386e1c92e07a4f82841813e1f3ffab3);\n", | |
" \n", | |
" \n", | |
"\n", | |
" marker_7f750be5ca313b7e9944ad7c231fa717.bindPopup(popup_515f7dc4194ea4a6f65d99797094482f)\n", | |
" ;\n", | |
"\n", | |
" \n", | |
" \n", | |
" \n", | |
" var marker_a1cd93ff3dfaca60623fea8d99cee280 = L.marker(\n", | |
" [32.9866, -83.6487],\n", | |
" {}\n", | |
" ).addTo(map_4c77671e29448fd2f401b34d4ce4f78c);\n", | |
" \n", | |
" \n", | |
" var icon_2e3b8313f7241b787e8ebc54971c6dac = L.AwesomeMarkers.icon(\n", | |
" {"extraClasses": "fa-rotate-0", "icon": "info-sign", "iconColor": "white", "markerColor": "blue", "prefix": "glyphicon"}\n", | |
" );\n", | |
" marker_a1cd93ff3dfaca60623fea8d99cee280.setIcon(icon_2e3b8313f7241b787e8ebc54971c6dac);\n", | |
" \n", | |
" \n", | |
" var popup_2dc15c0118f35a402e327f857d2e92fe = L.popup({"maxWidth": "100%"});\n", | |
"\n", | |
" \n", | |
" \n", | |
" var html_8d18737772045b39ff64e3aa7d640e3b = $(`<div id="html_8d18737772045b39ff64e3aa7d640e3b" style="width: 100.0%; height: 100.0%;">Georgia $42,518</div>`)[0];\n", | |
" popup_2dc15c0118f35a402e327f857d2e92fe.setContent(html_8d18737772045b39ff64e3aa7d640e3b);\n", | |
" \n", | |
" \n", | |
"\n", | |
" marker_a1cd93ff3dfaca60623fea8d99cee280.bindPopup(popup_2dc15c0118f35a402e327f857d2e92fe)\n", | |
" ;\n", | |
"\n", | |
" \n", | |
" \n", | |
" \n", | |
" var marker_12469bba8f6844a524a16f98e6d5ba02 = L.marker(\n", | |
" [41.1289, -98.2883],\n", | |
" {}\n", | |
" ).addTo(map_4c77671e29448fd2f401b34d4ce4f78c);\n", | |
" \n", | |
" \n", | |
" var icon_8409d82fd8c326bcc5019ee19fa91ec4 = L.AwesomeMarkers.icon(\n", | |
" {"extraClasses": "fa-rotate-0", "icon": "info-sign", "iconColor": "white", "markerColor": "blue", "prefix": "glyphicon"}\n", | |
" );\n", | |
" marker_12469bba8f6844a524a16f98e6d5ba02.setIcon(icon_8409d82fd8c326bcc5019ee19fa91ec4);\n", | |
" \n", | |
" \n", | |
" var popup_03abaa73c342afe46f388c221446cd26 = L.popup({"maxWidth": "100%"});\n", | |
"\n", | |
" \n", | |
" \n", | |
" var html_4d93a7212b3d7930b6eeb1bc4ad100f8 = $(`<div id="html_4d93a7212b3d7930b6eeb1bc4ad100f8" style="width: 100.0%; height: 100.0%;">Nebraska $63,290</div>`)[0];\n", | |
" popup_03abaa73c342afe46f388c221446cd26.setContent(html_4d93a7212b3d7930b6eeb1bc4ad100f8);\n", | |
" \n", | |
" \n", | |
"\n", | |
" marker_12469bba8f6844a524a16f98e6d5ba02.bindPopup(popup_03abaa73c342afe46f388c221446cd26)\n", | |
" ;\n", | |
"\n", | |
" \n", | |
" \n", | |
" \n", | |
" var marker_ddfdeec37c35ee319eafe849af25a549 = L.marker(\n", | |
" [39.0646, -105.3272],\n", | |
" {}\n", | |
" ).addTo(map_4c77671e29448fd2f401b34d4ce4f78c);\n", | |
" \n", | |
" \n", | |
" var icon_880dd7f47d73385fe637487a98ebdaa2 = L.AwesomeMarkers.icon(\n", | |
" {"extraClasses": "fa-rotate-0", "icon": "info-sign", "iconColor": "white", "markerColor": "blue", "prefix": "glyphicon"}\n", | |
" );\n", | |
" marker_ddfdeec37c35ee319eafe849af25a549.setIcon(icon_880dd7f47d73385fe637487a98ebdaa2);\n", | |
" \n", | |
" \n", | |
" var popup_81d14957c88c677418841818477a976b = L.popup({"maxWidth": "100%"});\n", | |
"\n", | |
" \n", | |
" \n", | |
" var html_36d4627f50596da07b0bff19ae7a041f = $(`<div id="html_36d4627f50596da07b0bff19ae7a041f" style="width: 100.0%; height: 100.0%;">Colorado $77,104</div>`)[0];\n", | |
" popup_81d14957c88c677418841818477a976b.setContent(html_36d4627f50596da07b0bff19ae7a041f);\n", | |
" \n", | |
" \n", | |
"\n", | |
" marker_ddfdeec37c35ee319eafe849af25a549.bindPopup(popup_81d14957c88c677418841818477a976b)\n", | |
" ;\n", | |
"\n", | |
" \n", | |
" \n", | |
" \n", | |
" var marker_3a9fd12d5f879a8356e145da12d0d334 = L.marker(\n", | |
" [42.2373, -71.5314],\n", | |
" {}\n", | |
" ).addTo(map_4c77671e29448fd2f401b34d4ce4f78c);\n", | |
" \n", | |
" \n", | |
" var icon_ec238cf260781d8dc896de93530dccbe = L.AwesomeMarkers.icon(\n", | |
" {"extraClasses": "fa-rotate-0", "icon": "info-sign", "iconColor": "white", "markerColor": "blue", "prefix": "glyphicon"}\n", | |
" );\n", | |
" marker_3a9fd12d5f879a8356e145da12d0d334.setIcon(icon_ec238cf260781d8dc896de93530dccbe);\n", | |
" \n", | |
" \n", | |
" var popup_e0086b36f0c04b8a6bee9892b477d9d1 = L.popup({"maxWidth": "100%"});\n", | |
"\n", | |
" \n", | |
" \n", | |
" var html_7e80a644618a9ec5f37a29753b114437 = $(`<div id="html_7e80a644618a9ec5f37a29753b114437" style="width: 100.0%; height: 100.0%;">Massachusetts $85,700</div>`)[0];\n", | |
" popup_e0086b36f0c04b8a6bee9892b477d9d1.setContent(html_7e80a644618a9ec5f37a29753b114437);\n", | |
" \n", | |
" \n", | |
"\n", | |
" marker_3a9fd12d5f879a8356e145da12d0d334.bindPopup(popup_e0086b36f0c04b8a6bee9892b477d9d1)\n", | |
" ;\n", | |
"\n", | |
" \n", | |
" \n", | |
"</script>\n", | |
"</html>\" style=\"position:absolute;width:100%;height:100%;left:0;top:0;border:none !important;\" allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe></div></div>" | |
] | |
}, | |
"metadata": {}, | |
"execution_count": 1 | |
} | |
], | |
"source": [ | |
"import folium\n", | |
"import pandas as pd\n", | |
"\n", | |
"# list of states - add or remove\n", | |
"list = [\"California\",\"New York\",\"Illinois\",\"Texas\",\"Washington\",\"Iowa\",\n", | |
" \"Florida\",\"Nevada\",\"Mississippi\",\"Georgia\",\"Nebraska\",\"Colorado\",\n", | |
" \"Massachusetts\"]\n", | |
"\n", | |
"# set criteria from census data column headings\n", | |
"criteria = \"Estimate of median household income 2019\"\n", | |
"dollarSign = \"$\"\n", | |
"percent = \"\"\n", | |
"\n", | |
"# United States lat and long\n", | |
"latitude = 37.0902\n", | |
"longitude = -95.7129\n", | |
"\n", | |
"# Create folium map\n", | |
"my_map = folium.Map(location=[latitude, longitude], zoom_start=4.5)\n", | |
"\n", | |
"# get json file of all states latitude and longitude\n", | |
"url = \"https://raw.githubusercontent.com/georgesb/files/main/states.json\"\n", | |
"df = pd.read_json(url)\n", | |
"\n", | |
"# get CensusData.csv file\n", | |
"url = \"https://raw.githubusercontent.com/georgesb/files/main/CensusData.csv\"\n", | |
"censusData = pd.read_csv(url)\n", | |
"\n", | |
"# functions\n", | |
"def setLatitude(state):\n", | |
" return float(df.loc[df[\"state\"] == state, \"latitude\"])\n", | |
"\n", | |
"def setLongitude(state):\n", | |
" return float(df.loc[df[\"state\"] == state, \"longitude\"])\n", | |
"\n", | |
"def setMarker(state):\n", | |
" latitude = setLatitude(state)\n", | |
" longitude = setLongitude(state)\n", | |
" searchResults = str(*censusData.loc[censusData[\"Area Name\"]==state,criteria])\n", | |
" folium.Marker(\n", | |
" location=[latitude, longitude],\n", | |
" popup=state + \" \" + dollarSign + searchResults + percent,\n", | |
" icon=folium.Icon(color=\"blue\", icon=\"info-sign\"),\n", | |
").add_to(my_map)\n", | |
"# end function section\n", | |
"\n", | |
"# loop to set markers for each state in list\n", | |
"for marker in list:\n", | |
" setMarker(marker)\n", | |
"\n", | |
"# Load the map\n", | |
"my_map\n" | |
] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment