|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "code", |
| 5 | + "execution_count": 1, |
| 6 | + "metadata": {}, |
| 7 | + "outputs": [], |
| 8 | + "source": [ |
| 9 | + "import pandas as pd\n", |
| 10 | + "import pygmaps\n", |
| 11 | + "import base64" |
| 12 | + ] |
| 13 | + }, |
| 14 | + { |
| 15 | + "cell_type": "code", |
| 16 | + "execution_count": 2, |
| 17 | + "metadata": {}, |
| 18 | + "outputs": [], |
| 19 | + "source": [ |
| 20 | + "API_KEY = open('api_key.txt').read()" |
| 21 | + ] |
| 22 | + }, |
| 23 | + { |
| 24 | + "cell_type": "code", |
| 25 | + "execution_count": 3, |
| 26 | + "metadata": { |
| 27 | + "scrolled": false |
| 28 | + }, |
| 29 | + "outputs": [ |
| 30 | + { |
| 31 | + "ename": "AttributeError", |
| 32 | + "evalue": "module 'pygmaps' has no attribute 'Map'", |
| 33 | + "output_type": "error", |
| 34 | + "traceback": [ |
| 35 | + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", |
| 36 | + "\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)", |
| 37 | + "\u001b[0;32m<ipython-input-3-d14105b589b7>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m map = pygmaps.Map(location=[-15.79, -47.88], api_key=API_KEY, zoom_start=12, show_pegman=False,\n\u001b[0m\u001b[1;32m 2\u001b[0m show_zoom_control=True, height='500px', style='redberry')\n\u001b[1;32m 3\u001b[0m \u001b[0mmap\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", |
| 38 | + "\u001b[0;31mAttributeError\u001b[0m: module 'pygmaps' has no attribute 'Map'" |
| 39 | + ] |
| 40 | + } |
| 41 | + ], |
| 42 | + "source": [ |
| 43 | + "map = pygmaps.Map(location=[-15.79, -47.88], api_key=API_KEY, zoom_start=12, show_pegman=False,\n", |
| 44 | + " show_zoom_control=True, height='500px', style='redberry')\n", |
| 45 | + "map" |
| 46 | + ] |
| 47 | + }, |
| 48 | + { |
| 49 | + "cell_type": "code", |
| 50 | + "execution_count": null, |
| 51 | + "metadata": {}, |
| 52 | + "outputs": [], |
| 53 | + "source": [ |
| 54 | + "map.html.splitlines()" |
| 55 | + ] |
| 56 | + }, |
| 57 | + { |
| 58 | + "cell_type": "code", |
| 59 | + "execution_count": null, |
| 60 | + "metadata": { |
| 61 | + "scrolled": true |
| 62 | + }, |
| 63 | + "outputs": [], |
| 64 | + "source": [ |
| 65 | + "dadosbr = 'https://raw.githubusercontent.com/kelvins/Municipios-Brasileiros/master/Municipios_Brasileiros.csv'\n", |
| 66 | + "df = pd.read_csv(dadosbr, sep=';')\n", |
| 67 | + "df.head()" |
| 68 | + ] |
| 69 | + }, |
| 70 | + { |
| 71 | + "cell_type": "code", |
| 72 | + "execution_count": null, |
| 73 | + "metadata": { |
| 74 | + "scrolled": false |
| 75 | + }, |
| 76 | + "outputs": [], |
| 77 | + "source": [ |
| 78 | + "import time\n", |
| 79 | + "from IPython.display import clear_output\n", |
| 80 | + "\n", |
| 81 | + "icongreen = 'https://bitcoin-obmen.com/i/green-circle.png'\n", |
| 82 | + "iconred = 'https://eshop.eca.ir/img/redcircle.png.pagespeed.ce.GbuWBUNpkq.png'\n", |
| 83 | + "icon = iconred\n", |
| 84 | + "for UF in df.UF.unique():\n", |
| 85 | + " data = df.query('UF == @UF').reset_index(drop=True).head(50)\n", |
| 86 | + "\n", |
| 87 | + " m = pygmaps.Map(API_KEY, markers = data[['Latitude', 'Longitude']], \n", |
| 88 | + " labels=data['Nome do Município'], icon=icon, zoom=6, height='400px', width='50%',\n", |
| 89 | + " title=f'Municípios de {UF}', show_pegman=False, show_zoomcontrol=False)\n", |
| 90 | + " \n", |
| 91 | + " display(HTML(m.html), display_id=True) \n", |
| 92 | + " time.sleep(2)\n", |
| 93 | + " clear_output()" |
| 94 | + ] |
| 95 | + } |
| 96 | + ], |
| 97 | + "metadata": { |
| 98 | + "kernelspec": { |
| 99 | + "display_name": "Python 3", |
| 100 | + "language": "python", |
| 101 | + "name": "python3" |
| 102 | + }, |
| 103 | + "language_info": { |
| 104 | + "codemirror_mode": { |
| 105 | + "name": "ipython", |
| 106 | + "version": 3 |
| 107 | + }, |
| 108 | + "file_extension": ".py", |
| 109 | + "mimetype": "text/x-python", |
| 110 | + "name": "python", |
| 111 | + "nbconvert_exporter": "python", |
| 112 | + "pygments_lexer": "ipython3", |
| 113 | + "version": "3.6.3" |
| 114 | + } |
| 115 | + }, |
| 116 | + "nbformat": 4, |
| 117 | + "nbformat_minor": 2 |
| 118 | +} |
0 commit comments