建设背景虚化使用数据选择控件帧
问题描述:
我有一个数据帧DF与列“位置”(少数细胞没有值) -建设背景虚化使用数据选择控件帧
location
US
India
US
Japan
US
India
我想创建一个单一选择的Widget使用背景虚化的价值观包含在位置列中。我写下面的代码 -
location = Select(title="Location", value="All",
options=df["location"].unique())
这给了我一个错误 -
ValueError: expected an element of List(Either(String, Tuple(String,
String))), got array(['US', 'India', 'EMEA', nan, 'Japan'],
dtype=object)
答
您需要将熊猫系列转换成一个列表。
options=df["location"].unique().tolist()