Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

choromap = go.Figure(data=[data], layout = layout)

import pandas as pd
import io
import plotly.graph_objs as go 
from plotly.offline import plot

# the data is different but it works

txt = """   state   abv ibu id  beer    style   ounces  brewery city
0   AK  25  17  25  25.0    25.0    25  25  25
1   AL  10  9   10  10.0    10.0    10  10  10
2   AR  5   1   5   5.0 5.0 5   5   5
3   AZ  44  24  47  47.0    46.0    47  47  47
4   CA  182 135 183 183.0   183.0   183 183 183
5   CO  250 146 265 265.0   263.0   265 265 265
6   CT  27  6   27  27.0    27.0    27  27  27
7   DC  8   4   8   8.0 8.0 8   8   8
8   DE  1   1   2   2.0 2.0 2   2   2
9   FL  56  37  58  58.0    58.0    58  58  58
10  GA  16  7   16  16.0    16.0    16  16  16
"""

gb_state = pd.read_csv(io.StringIO(txt), delim_whitespace=True)


data = dict(type='choropleth',
            locations=gb_state['state'],
            locationmode='USA-states',
            text=gb_state['state'],
            z=gb_state['beer'],
            ) 

layout = dict(geo = dict(scope='usa',
                         showlakes= False)
             )

choromap = go.Figure(data=[data], layout=layout)
plot(choromap)
Comment

PREVIOUS NEXT
Code Example
Python :: pickling and unpickling in python 
Python :: pandas merge certain columns 
Python :: loop through 2 items python 
Python :: or operator in django queryset 
Python :: get last element of a list python 
Python :: deleting dataframe row in pandas based on column value 
Python :: python difflib compare two strings 
Python :: python add element to array 
Python :: flask abort return json 
Python :: python file size in bytes 
Python :: get sum of a range from user input 
Python :: draw bounding box on image python opencv 
Python :: get time format python2 hours minutes seconds milliseconds 
Python :: how to hide a widget in tkinter python 
Python :: pandas index from 1 
Python :: shebang python 
Python :: continual vs continuous 
Python :: django objects.create() 
Python :: try open file 
Python :: create and use python classes 
Python :: twitter bot python 
Python :: python set cwd to script directory 
Python :: how to earse special chrat¥cter from string in python 
Python :: remove a column from dataframe 
Python :: How to recursively sort the elements of a stack, in Python? 
Python :: loop through a column in pandas 
Python :: python check if 3 values are equal 
Python :: merge two series by index 
Python :: find duplicates in python list 
Python :: python read entire file 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =