Python 我应该如何使用Bokeh和Pandas绘制分类数据的散点图?

Python 我应该如何使用Bokeh和Pandas绘制分类数据的散点图?,python,pandas,bokeh,Python,Pandas,Bokeh,我有一个包含以下数据的数据框: Merchant | Non-Merchant | Num of Chats Received | Num of Chats Made 1 | 0 | 80 | 50 0 | 1 | 60 | 30 1 | 0 | 70 | 40 0

我有一个包含以下数据的数据框:

Merchant | Non-Merchant | Num of Chats Received | Num of Chats Made
1        | 0            | 80                    | 50
0        | 1            | 60                    | 30
1        | 0            | 70                    | 40
0        | 1            | 50                    | 20
我希望能够在散点图上绘制两种不同类型的用户(商家、非商家),比较它们的[Num of Chats Received,y axis]

在上述数据中

商户是指在商户栏中标记为“1”的商户,以及

非商户是指商户栏中标记为“1”的商户

它是二进制的,没有[1,1]


我是Bokeh和Data的新手,也就是说,一般来说,假设Bokeh是我的首选方法,我应该怎么做呢?

这里有一种使用Bokeh的方法

代码:


Hi@rbierman,我试了一下,但我的情节是空白的):知道为什么吗?我应该提到的是,我的值范围从一位数到800~。解决了!去检查数据类型,发现我的1和0是字符串类型。非常感谢。哦,太好了!如果你对这个答案感到满意,请接受它,这样问题就结束了
from bokeh.plotting import figure, output_file, show
import pandas as pd

data = {'Merchant':[1,0,1,0],
        'Non-Merchant':[0,1,0,1],
        'Num of Chats Received':[80,60,70,50],
        'Num of Chats Made':[50,30,40,20]}

df = pd.DataFrame(data)

merchant_chats_made = list(df[df['Merchant'] == 1]['Num of Chats Made'])
merchant_chats_received = list(df[df['Merchant'] == 1]['Num of Chats Received'])
non_merchant_chats_made = list(df[df['Non-Merchant'] == 1]['Num of Chats Made'])
non_merchant_chats_received = list(df[df['Non-Merchant'] == 1]['Num of Chats Received'])

output_file('merchant.html')

p = figure(plot_width=400, plot_height=400)
p.circle(merchant_chats_made,
         merchant_chats_received,
         size=10,color='red',alpha=0.5,
         legend='Merchant')

p.circle(non_merchant_chats_made,
         non_merchant_chats_received,
         size=10,color='blue',alpha=0.5,
         legend='Non-Merchant')

p.xaxis.axis_label = 'Chats Made'
p.yaxis.axis_label = 'Chats Received'
p.legend.location = 'top_left'

show(p)