-
Notifications
You must be signed in to change notification settings - Fork 1
/
bairros.py
26 lines (19 loc) · 6.93 KB
/
bairros.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import plotly.plotly as py
import plotly.graph_objs as go
import plotly
import json
import urllib3
plotly.tools.set_credentials_file(username='hugdiniz34c7', api_key='iDYl6fJK68O6QkCGtXwv')
http = urllib3.PoolManager()
#r = http.request('GET', 'http://localhost:8080/violence/by/neighborhood');
texto = '[{"name": "Centro", "amount": "31"}, {"name": "Tijuca", "amount": "18"}, {"name": "Bangu", "amount": "18"}, {"name": "Bonsucesso", "amount": "15"}, {"name": "Barra da Tijuca", "amount": "15"}, {"name": "Realengo", "amount": "12"}, {"name": "Botafogo", "amount": "11"}, {"name": "Santa Teresa", "amount": "11"}, {"name": "Campo Grande", "amount": "10"}, {"name": "Ilha", "amount": "9"}, {"name": "M\u00e9ier", "amount": "9"}, {"name": "Pra\u00e7a Seca", "amount": "9"}, {"name": "Madureira", "amount": "8"}, {"name": "Mar\u00e9", "amount": "8"}, {"name": "Caju", "amount": "7"}, {"name": "Complexo do Alem\u00e3o", "amount": "7"}, {"name": "S\u00e3o Crist\u00f3v\u00e3o", "amount": "7"}, {"name": "Engenho de Dentro", "amount": "7"}, {"name": "Coelho Neto", "amount": "6"}, {"name": "Copacabana", "amount": "6"}, {"name": "Freguesia (Jacarepagu\u00e1)", "amount": "6"}, {"name": "Pavuna", "amount": "6"}, {"name": "Costa Barros", "amount": "6"}, {"name": "N\u00e3o Informado", "amount": "6"}, {"name": "Graja\u00fa", "amount": "5"}, {"name": "Tanque", "amount": "5"}, {"name": "Iraj\u00e1", "amount": "5"}, {"name": "Maracan\u00e3", "amount": "5"}, {"name": "Ipanema", "amount": "5"}, {"name": "Engenho da Rainha", "amount": "5"}, {"name": "Piedade", "amount": "5"}, {"name": "Cidade de Deus", "amount": "4"}, {"name": "Catumbi", "amount": "4"}, {"name": "Santo Cristo", "amount": "4"}, {"name": "Quintino Bocaiuva", "amount": "4"}, {"name": "Penha", "amount": "4"}, {"name": "Vista Alegre", "amount": "4"}, {"name": "Recreio dos Bandeirantes", "amount": "4"}, {"name": "Vila Isabel", "amount": "4"}, {"name": "Santa Cruz", "amount": "4"}, {"name": "Engenho Novo", "amount": "4"}, {"name": "Olaria", "amount": "3"}, {"name": "Cordovil", "amount": "3"}, {"name": "Oswaldo Cruz", "amount": "3"}, {"name": "Estrada da Saudade", "amount": "3"}, {"name": "Rocha", "amount": "3"}, {"name": "Cidade Universit\u00e1ria", "amount": "3"}, {"name": "Meier", "amount": "3"}, {"name": "Padre Miguel", "amount": "3"}, {"name": "Gale\u00e3o", "amount": "3"}, {"name": "Paci\u00eancia", "amount": "3"}, {"name": "P\u00e9 Pequeno", "amount": "3"}, {"name": "Manguinhos", "amount": "3"}, {"name": "Rua Marechal Floriano", "amount": "2"}, {"name": "Vila Valqueire", "amount": "2"}, {"name": "Riachuelo", "amount": "2"}, {"name": "Curicica", "amount": "2"}, {"name": "Grajau", "amount": "2"}, {"name": "Cacuia", "amount": "2"}, {"name": "Rua F\u00e9lix da Cunha", "amount": "2"}, {"name": "Flamengo", "amount": "2"}, {"name": "Catete", "amount": "2"}, {"name": "Pilares", "amount": "2"}, {"name": "Mangueira", "amount": "2"}, {"name": "Guadalupe", "amount": "2"}, {"name": "Jacarezinho", "amount": "2"}, {"name": "Ramos", "amount": "2"}, {"name": "Vicente de Carvalho", "amount": "2"}, {"name": "Sampaio", "amount": "2"}, {"name": "Todos os Santos", "amount": "2"}, {"name": "Inhauma", "amount": "2"}, {"name": "\u00c1gua Santa", "amount": "2"}, {"name": "Encantado", "amount": "2"}, {"name": "Banc\u00e1rios", "amount": "2"}, {"name": "Est\u00e1cio", "amount": "2"}, {"name": "Cocot\u00e1", "amount": "2"}, {"name": "Rua V\u00edtor Meireles", "amount": "1"}, {"name": "Gradim", "amount": "1"}, {"name": "Vaz Lobo", "amount": "1"}, {"name": "Cosmos", "amount": "1"}, {"name": "Venda da Cruz", "amount": "1"}, {"name": "Palhada", "amount": "1"}, {"name": "Rua Xing\u00fa", "amount": "1"}, {"name": "Rocinha", "amount": "1"}, {"name": "Acari", "amount": "1"}, {"name": "Cachambi", "amount": "1"}, {"name": "Rua Marqu\u00eas de Valen\u00e7a", "amount": "1"}, {"name": "Rio do Ouro", "amount": "1"}, {"name": "Jardim Sulacap", "amount": "1"}, {"name": "Bento Ribeiro", "amount": "1"}, {"name": "Jardim Bot\u00e2nico", "amount": "1"}, {"name": "Br\u00e1s de Pina", "amount": "1"}, {"name": "Rua Doutor Leal", "amount": "1"}, {"name": "Ing\u00e1", "amount": "1"}, {"name": "Praca da Bandeira", "amount": "1"}, {"name": "Rua Alzira Brand\u00e3o", "amount": "1"}, {"name": "Avenida do Ex\u00e9rcito", "amount": "1"}, {"name": "Humait\u00e1", "amount": "1"}, {"name": "Laranjeiras", "amount": "1"}, {"name": "Turia\u00e7u", "amount": "1"}, {"name": "Barros Filho", "amount": "1"}, {"name": "Belford Roxo", "amount": "1"}, {"name": "Rua Volunt\u00e1rios da P\u00e1tria", "amount": "1"}, {"name": "Gard\u00eania Azul", "amount": "1"}, {"name": "Vig\u00e1rio Geral", "amount": "1"}, {"name": "Hon\u00f3rio Gurgel", "amount": "1"}, {"name": "Leblon", "amount": "1"}, {"name": "Rocha Miranda", "amount": "1"}, {"name": "S\u00e3o Francisco", "amount": "1"}, {"name": "Higien\u00f3polis", "amount": "1"}, {"name": "Aboli\u00e7\u00e3o", "amount": "1"}, {"name": "Coelho", "amount": "1"}, {"name": "Rua Uruguai", "amount": "1"}, {"name": " complexo da Penha.", "amount": "1"}, {"name": "Inha\u00fama", "amount": "1"}, {"name": "Rua Jo\u00e3o Pessoa", "amount": "1"}, {"name": "G\u00e1vea", "amount": "1"}, {"name": "Del Castilho", "amount": "1"}, {"name": "Leme", "amount": "1"}, {"name": "Rua Adriano", "amount": "1"}, {"name": "Vila Meriti", "amount": "1"}, {"name": "Jardim Tupiara", "amount": "1"}, {"name": "Parada de Lucas", "amount": "1"}, {"name": "Rio Comprido", "amount": "1"}, {"name": "Olinda", "amount": "1"}, {"name": "Pechincha", "amount": "1"}, {"name": "Jardim Jose Bonifacio", "amount": "1"}, {"name": "S\u00e3o Jos\u00e9", "amount": "1"}, {"name": "Cidade Nova", "amount": "1"}, {"name": "Rua Cl\u00f3vis Bevilaqua", "amount": "1"}, {"name": "Jardim Gl\u00e1ucia", "amount": "1"}, {"name": "Camar\u00e3o", "amount": "1"}, {"name": "Parque Sao Vicente", "amount": "1"}, {"name": "S\u00e3o Francisco Xavier", "amount": "1"}, {"name": "Col\u00e9gio", "amount": "1"}, {"name": "Jacarepagu\u00e1", "amount": "1"}, {"name": "Vila Mimosa", "amount": "1"}, {"name": "Rua Dona Delfina", "amount": "1"}, {"name": "Portuguesa", "amount": "1"}, {"name": "Lapa", "amount": "1"}, {"name": "Itatiaia", "amount": "1"}, {"name": "Avenida Ataulfo de Paiva", "amount": "1"}, {"name": "Marechal Hermes", "amount": "1"}, {"name": "Anil", "amount": "1"}, {"name": "Rua Doutor Sardinha", "amount": "1"}, {"name": "Anchieta", "amount": "1"}, {"name": "Rua Aristides Caire", "amount": "1"}, {"name": "Galo Branco", "amount": "1"}, {"name": "Parque Chuno", "amount": "1"}, {"name": "Rua Eduardo Guinle", "amount": "1"}, {"name": "Penha Circular", "amount": "1"}, {"name": "Itanhang\u00e1", "amount": "1"}, {"name": "Gl\u00f3ria", "amount": "1"}, {"name": "Jacarepagua", "amount": "1"}, {"name": "Rua Almirante Alexandrino", "amount": "1"}, {"name": "Taquara", "amount": "1"}, {"name": "Ricardo de Albuquerque", "amount": "1"}]'
bairros = json.loads(texto)
x = []
y = []
for bairro in bairros:
x.append(bairro['name'])
y.append(int(bairro['amount']))
print(x)
print(y)
data = [go.Bar(x=x,y=y)]
py.iplot(data, filename='basic-bar')