AttributeError: 'list' object has no attribute 'rgb2hex'
AttributeError: 'list' object has no attribute 'rgb2hex'
我在尝试为我的数据应用 Kmeans 聚类并尝试将聚类映射到叶*
map_clusters = folium.Map(location=[latitude, longitude], zoom_start=11)
# set color scheme for the clusters
x = np.arange(kclusters)
ys = [i + x + (i*x)**2 for i in range(kclusters)]
colors_array = cm.rainbow(np.linspace(0, 1, len(ys)))
rainbow = [colors.rgb2hex(i) for i in colors_array]
# add markers to the map
markers_colors = []
for lat, lon, poi, cluster in zip(banglore_merged['latitude'], banglore_merged['longitude'], banglore_merged['location'], banglore_merged['Cluster Labels']):
label = folium.Popup(str(poi) + ' Cluster ' + str(cluster), parse_html=True)
folium.CircleMarker(
[lat, lon],
radius=5,
popup=label,
color=rainbow[int(cluster)-1],
fill=True,
fill_color=rainbow[int(cluster)-1],
fill_opacity=0.7).add_to(map_clusters)
map_clusters
错误:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-50-8e09b66c0be6> in <module>
6 ys = [i + x + (i*x)**2 for i in range(kclusters)]
7 colors_array = cm.rainbow(np.linspace(0, 1, len(ys)))
----> 8 rainbow = [colors.rgb2hex(i) for i in colors_array]
9
10 # add markers to the map
<ipython-input-50-8e09b66c0be6> in <listcomp>(.0)
6 ys = [i + x + (i*x)**2 for i in range(kclusters)]
7 colors_array = cm.rainbow(np.linspace(0, 1, len(ys)))
----> 8 rainbow = [colors.rgb2hex(i) for i in colors_array]
9
10 # add markers to the map
AttributeError: 'list' object has no attribute 'rgb2hex'
希望您能找到我的查询的答案。提前致谢
我猜你正在将一个空数据集传递给变量。请更改名称。
rainbow = [colors.rgb2hex(i) for i in colors_array]
我在尝试为我的数据应用 Kmeans 聚类并尝试将聚类映射到叶*
map_clusters = folium.Map(location=[latitude, longitude], zoom_start=11)
# set color scheme for the clusters
x = np.arange(kclusters)
ys = [i + x + (i*x)**2 for i in range(kclusters)]
colors_array = cm.rainbow(np.linspace(0, 1, len(ys)))
rainbow = [colors.rgb2hex(i) for i in colors_array]
# add markers to the map
markers_colors = []
for lat, lon, poi, cluster in zip(banglore_merged['latitude'], banglore_merged['longitude'], banglore_merged['location'], banglore_merged['Cluster Labels']):
label = folium.Popup(str(poi) + ' Cluster ' + str(cluster), parse_html=True)
folium.CircleMarker(
[lat, lon],
radius=5,
popup=label,
color=rainbow[int(cluster)-1],
fill=True,
fill_color=rainbow[int(cluster)-1],
fill_opacity=0.7).add_to(map_clusters)
map_clusters
错误:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-50-8e09b66c0be6> in <module>
6 ys = [i + x + (i*x)**2 for i in range(kclusters)]
7 colors_array = cm.rainbow(np.linspace(0, 1, len(ys)))
----> 8 rainbow = [colors.rgb2hex(i) for i in colors_array]
9
10 # add markers to the map
<ipython-input-50-8e09b66c0be6> in <listcomp>(.0)
6 ys = [i + x + (i*x)**2 for i in range(kclusters)]
7 colors_array = cm.rainbow(np.linspace(0, 1, len(ys)))
----> 8 rainbow = [colors.rgb2hex(i) for i in colors_array]
9
10 # add markers to the map
AttributeError: 'list' object has no attribute 'rgb2hex'
希望您能找到我的查询的答案。提前致谢
我猜你正在将一个空数据集传递给变量。请更改名称。
rainbow = [colors.rgb2hex(i) for i in colors_array]