我是pandas和bokeh的新手,我正在尝试从pandas dataframe创建散点图。然而,我一直得到以下错误:
new_data[colname] = df[colname].tolist()
AttributeError: 'DataFrame' object has no attribute 'tolist'
使用 bokeh 提供的虚拟数据(从 bokeh.sampledata.iris 导入 flowers as data)时,散点图可以正常运行。
type tsneX tsneY +50.000 columns
0 A 53.828863 20.740931
1 B 57.816909 18.478468
2 A 55.913429 22.948167
3 C 56.603005 15.738954
scatter = Scatter(df, x='tsneX', y='tsneY',
color='type', marker='type',
title='t-sne',
legend=True)
编辑: 我没有使用tolist(),但Bokeh的Scatter()使用了它并产生了下面的错误。
print(new_data.head(5))
并解释一下你的X
和Y
列是什么? - MaxU - stand with Ukraine