gpt4 book ai didi

python - Bokeh:ColumnDataSource 未在 Vbar 上渲染

转载 作者:行者123 更新时间:2023-12-01 01:15:02 25 4
gpt4 key购买 nike

尝试将以下内容读入 vbar Bokeh 图表,但它不会渲染空白图形之外的任何内容。

Index | Sub Call Type      | Calls   |Total AHT
0 | Standard Checklist | 33111 |00:07:27
1 | About FSS | 9447 |00:04:40

尝试执行以下操作:

import pandas as pd
from bokeh.io import show, output_file
from bokeh.plotting import figure, ColumnDataSource

data = pd.read_csv("Desktop/Graph.csv")

output_file("bar_pandas.html")

source = ColumnDataSource(data=data)

p = figure(plot_height=350,title="Business Heatmap FYTD")

p.vbar(x="Sub Call Type",top="Calls",width=0.5,source=source)

show(p)

感谢您的帮助

最佳答案

您忘记指定数据为 categorical 。这可以通过 x_range=list(catagories)

来完成
import pandas as pd
from bokeh.io import show, output_file
from bokeh.plotting import figure, ColumnDataSource

data = pd.DataFrame.from_dict({"Sub Call Type": ["Standard Checklist", "About FFS"], "Calls": [33111, 9447], "Total AHT": ["00:07:27", "00:04:40"]})

output_file("bar_pandas.html")

source = ColumnDataSource(data=data)

p = figure(plot_height=350,title="Business Heatmap FYTD", x_range=data["Sub Call Type"])

p.vbar(x="Sub Call Type",top="Calls",width=0.5,source=source)

show(p)

关于python - Bokeh:ColumnDataSource 未在 Vbar 上渲染,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54432870/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com