我正在尝试在Jupyter笔记本中使用Plotly的示例代码来处理“缺失值的矩形数据” use case on their site。将代码从他们的网站逐字复制到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()
答案 0 :(得分:1)
您必须将plotly
和path
的新sunburst
关键字参数升级到treemap
版本4.5.0:)
答案 1 :(得分:0)
使用这些命令,它将运行
Sub Run_Macro()
Set objExcel = CreateObject("Excel.Application")
Path = "F:\RO\Data Management_Mar'20"
If Dir(Path, vbDirectory) = "" Then
MsgBox "File does not exist !!!"
End
Else
'Resolutuion : Apostrophe (') characters doubled-up
objExcel.Application.Run _
"'F:\RO\Data Management_Mar''20\1.0 Test File Sep''20.xlsm'!Module1.MyMacro"
End If
objExcel.DisplayAlerts = False
objExcel.Application.Quit
Set objExcel = Nothing
End Sub
要么
pip install --upgrade plotly
答案 2 :(得分:0)
!pip install --upgrade plotly
它工作正常。这是由于版本不兼容。
执行此操作后,如果您使用内部代码编辑器,则必须重新启动内核..
但是,如果您使用像 GOOGLE COLLAB 这样的在线编辑器或其他任何东西,您只需刷新浏览器。
#更新
如果您还有任何问题,请尝试此特定版本,而不是停留在它上面。
!pip install plotly==4.8.2
这是为了更好地理解的代码...
fig = px.sunburst(df1,
path =['CourseP','CourseS', 'Gender'],
title = "Complete overview of students with their course and year of college")
fig.show(renderer="colab")