我的想法是准备一张美国地图,上面标明“出生”的NBA球员人数最多。在
我找到了这个教程https://plot.ly/python/choropleth-maps/
我试图这样修改代码:
import plotly.plotly as py
import pandas as pd
df = pd.ExcelFile('playersnba.xlsx')
data = [ dict(
type = 'choropleth',
locations = df['State'],
z = df['Numbers'],
text = df['State'],
colorscale = [[0,"rgb(5, 10, 172)"],[0.35,"rgb(40, 60, 190)"],[0.5,"rgb(70, 100, 245)"],\
[0.6,"rgb(90, 120, 245)"],[0.7,"rgb(106, 137, 247)"],[1,"rgb(220, 220, 220)"]],
autocolorscale = False,
reversescale = True,
marker = dict(
line = dict (
color = 'rgb(180,180,180)',
width = 0.5
) ),
colorbar = dict(
autotick = False,
tickprefix = '#',
title = 'players'),
) ]
我的问题是:
^{pr2}$
将excel文件读入数据帧的方法是使用
ExcelFile.parse()
,而不仅仅是ExcelFile。所以:相关问题 更多 >
编程相关推荐