我正在尝试使用以下字典映射值:
color_class = {("red","maroon","burgundy"):"red hue",
("sky","turquoiseblue","darkblue","cyan","blue","royalblue"):"blue hue",
("lightpink","babypink","pink"):"pink hue",
("purple","mauve","violet"):"purple hue",
("green","seagreen","bluegreen","mint"):"green hue",
("brown"):"brown hue",
("yellow"):"yellow hue",
("orange"):"orange hue",
("black","white","grey"):"neutral hue",
("nocolor"):"none"}
我希望字典中的各个值在此数据框中显示为单独的列(标题为“色相”):
我该如何实现?
答案 0 :(得分:0)
如果您想要字典中的所有值,则可以使用dict.values()。这将为您提供字典中的值的列表。
您可以将此添加为数据框中的一列。您可以像下面的示例中那样一步。
df['hue'] = color_class.values()