python - Plotly Sunburst - TypeError: sunburst() got an unexpected keyword argument 'path'
问题描述
我试图让 Plotly 的示例代码在 jupyter 笔记本中工作,用于他们网站上的“缺少值的矩形数据”用例。将代码从他们的站点逐字复制到 jupyter 笔记本中,我得到以下 TypeError,有什么想法吗?
TypeError: sunburst() got an unexpected keyword argument 'path'
代码:
import plotly.express as px
import pandas as pd
vendors = ["A", "B", "C", "D", None, "E", "F", "G", "H", None]
sectors = ["Tech", "Tech", "Finance", "Finance", "Other",
"Tech", "Tech", "Finance", "Finance", "Other"]
regions = ["North", "North", "North", "North", "North",
"South", "South", "South", "South", "South"]
sales = [1, 3, 2, 4, 1, 2, 2, 1, 4, 1]
df = pd.DataFrame(
dict(vendors=vendors, sectors=sectors, regions=regions, sales=sales)
)
print(df)
fig = px.sunburst(df, path=['regions', 'sectors', 'vendors'], values='sales')
fig.show()
解决方案
您必须升级到plotly
版本 4.5.0 才能获得新的path
关键字参数sunburst
和treemap
:)
推荐阅读
- opencv - 在运行交叉编译的 cpp 二进制文件时运行 poky 2.1.3 的 h3ulcb 中未处理的 2 级转换错误
- r - 多个 R Shiny 进程
- javascript - Google-Sheets - 根据单元格值打破循环
- bash - docker-compose 动态查看容器是否已启动(或:docker-compose 计划?)
- c# - 为什么这个方法调用不明确?
- qt - 边距和锚点在 Qt、QML 中效果不佳
- android - 如何保护类不被 MINIFY_ENABLED 删除?
- concurrency - 每个队列在 spring-rabbitmq 中动态创建容器
- python - 将嵌套列表的每个元素写入 CSV 的单独列
- mongodb - 如何使用 loopback4 在 MonogoDB 数据库中创建用户