'''
perstate = df[df['State'] != '']['State'].value_counts().to_dict()
data = [dict(
type = 'choropleth',autocolorscale = False,colorscale = 'Blues',reversescale = True,locations = list(perstate.keys()),locationmode = 'USA-states',text = list(perstate.values()),z = list(perstate.values()),marker = dict(
line = dict(
color = 'rgb(255,255,255)',width = 2)
),)]
layout = dict(
title = 'Bachelor contestants by State',geo = dict(
scope = 'usa',projection = dict(type = 'albers usa'),countrycolor = 'rgb(255,showlakes = True,lakecolor = 'rgb(255,255)')
)
figure = dict(data = data,layout = layout)
iplot(figure)
'''
这给了我以下内容:
TypeError
追溯(最近一次通话结束)
<ipython-input-294-8cdc028c4fa9> in <module>
7 colorscale = 'Blues',8 reversescale = True,----> 9 locations = list(perstate.keys()),10 locationmode = 'USA-states',11 text = list(perstate.values()),TypeError: 'list' object is not callable
今天早些时候工作了,我什么都没改变。为什么会这样呢?我在Kaggle使用笔记本电脑。我正在尝试获取“州”列,其中包含州的缩写,我想绘制一个热图。