使用数据帧在散景中构建选择小部件



我有一个带有"位置"列的数据框架DF(几个没有值的单元格( -

location
US
India
US
Japan
US
India

我想使用Bokeh创建一个单个选择小部件,其中包含位置列中的值。我正在写下代码 -

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()

最新更新