我应该如何处理python中的不可订阅问题?

2024-09-27 21:32:32 发布

您现在位置:Python中文网/ 问答频道 /正文

我的想法是准备一张美国地图,上面标明“出生”的NBA球员人数最多。在

My excel

我找到了这个教程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}$

Tags: importfalsedfas地图教程rgbplotly
1条回答
网友
1楼 · 发布于 2024-09-27 21:32:32

将excel文件读入数据帧的方法是使用ExcelFile.parse(),而不仅仅是ExcelFile。所以:

df = pd.ExcelFile.parse('playersnba.xlsx')

相关问题 更多 >

    热门问题