首页 > 解决方案 > 有错误的 Holoviews 条返回 TypeError:不支持的操作数类型 -:'str' 和 'float'

问题描述

我尝试用错误做一个全息条图。

单独的条形图正在工作,但是当我添加错误图时,我收到以下错误消息:

TypeError: unsupported operand type(s) for -: 'str' and 'float'

版本是:bokeh=2.0.2,holoviews=1.13.3

pandas DataFrame 中的数据对于 Cat1 和 Cat2 是分类的,对于 Value 是浮动的:

    Cat1 Cat2   Value
0   A   C   712.788035
1   A   C   532.259371
2   A   D   381.516398
3   A   D   281.396654
4   B   C   412.779620
5   B   C   281.261148
6   B   D   271.261342
7   B   D   0.000000

我的代码如下所示:

bars   = hv.Bars(df,kdims=['Cat1','Cat2'], vdims=['Value'])
errors = hv.ErrorBars(df, kdims=['Cat1','Cat2'], vdims=['Value'])
plot = bars * errors
plot

标签: pythonholoviews

解决方案


推荐阅读