m0_50859403
2022-04-13 17:23
采纳率: 0%
浏览 32

使用for in遍历列表的时候,得出的结果变成了负数

问题遇到的现象和发生背景

代码是用Kmeans做主色提取,遍历出来的xyz值和列表里的都相差256

问题相关代码,请勿粘贴截图
cluster_map = pd.DataFrame()
cluster_map['position'] = img_cor
cluster_map['cluster'] = kmeans.labels_
cluster_map['x'] = [i[0] for i in cluster_map['position']]
cluster_map['y'] = [i[1] for i in cluster_map['position']]
cluster_map['z'] = [i[2] for i in cluster_map['position']]
cluster_map['color'] = [hex_colors[x] for x in cluster_map['cluster']]
cluster_map['color_name'] = [color_name[x] for x in cluster_map['color']]
print(cluster_map)
运行结果及报错内容

img

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

相关推荐 更多相似问题