I want to make country map from code:
import chart_studio.plotly as py
import pandas as pd
df = pd.read_csv('MS.csv')
data = [ dict(
type = 'choropleth',
locations = df['CODE'],
z = df['MS'],
text = df['COUNTRY'],
colorscale = [[0,"rgb(5, 10, 172)"],[0.35,"rgb(40, 60, 190)"],[0.5,"rgb(70, 100, 245)"],\
[0.6,"rgb(00, 120, 245)"],[0.7,"rgb(06, 130, 247)"],[1,"rgb(255, 255, 259)"]],
autocolorscale = False,
reversescale = True,
marker = dict(
line = dict (
color = 'rgb(180,180,180)',
width = 0.5
) ),
colorbar = dict(
autotick = False,
tickprefix = None,
title = 'ASes'),
) ]
layout = dict(
title = 'MS COUNTRY',
geo = dict(
showframe = False,
showcoastlines = False,
projection = dict(
type = 'Mercator'
)
)
)
fig = dict( data=data, layout=layout )
py.plot( fig, validate=False, filename='d3-world-map' )
This produces a fine map with Python 3 but when I run on spyder Anaconda It is giving error:
Traceback (most recent call last):
File "<ipython-input-8-fe3c136d7898>", line 1, in <module>
runfile('C:/charts/plot (2).py', wdir='C:/charts')
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile
execfile(filename, namespace)
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/charts/plot (2).py", line 38, in <module>
py.plot( fig, validate=False, filename='d3-world-map' )
File "C:\ProgramData\Anaconda3\lib\site-packages\chart_studio\plotly\plotly.py", line 265, in plot
figure, grid = _extract_grid_from_fig_like(figure)
File "C:\ProgramData\Anaconda3\lib\site-packages\chart_studio\plotly\plotly.py", line 1870, in _extract_grid_from_fig_like
trace_dict, reference_trace, grid, path + "data.{}.".format(i)
File "C:\ProgramData\Anaconda3\lib\site-packages\chart_studio\plotly\plotly.py", line 1800, in _extract_grid_graph_obj
"{path}{prop}.".format(path=path, prop=prop),
File "C:\ProgramData\Anaconda3\lib\site-packages\chart_studio\plotly\plotly.py", line 1800, in _extract_grid_graph_obj
"{path}{prop}.".format(path=path, prop=prop),
File "C:\ProgramData\Anaconda3\lib\site-packages\chart_studio\plotly\plotly.py", line 1782, in _extract_grid_graph_obj
for prop in list(obj_dict.keys()):
AttributeError: 'str' object has no attribute 'keys'
How can I solve this?
