gpt4 book ai didi

python - 类型错误 : scatter() got an unexpected keyword argument 'trendline_options' (Plotly, Python)

转载 作者:行者123 更新时间:2023-12-05 03:38:54 24 4
gpt4 key购买 nike

我收到错误:

TypeError: scatter() got an unexpected keyword argument 'trendline_options'

尝试使用 plotly express 调整低趋势线的平滑度时。

这是我的图形代码:

fig = px.scatter(dfg, x="Yr_Mnth", y="Episode_Count", color = "Target",
labels={"Episode_Count": tally + " per Shift",
"Target":"Target",
"Yr_Mnth": "Date" },
trendline='lowess',trendline_options= dict(frac=0.1), title="Aggregate Behavior Data: " + patient + " - " + today)
fig.update_xaxes(tickangle=45,)
fig.update_layout(template = 'plotly_white',hovermode="x unified")

数据集(dfg):

Yr_Mnth                         Target              Episode_Count
2020-08-01 Aggression 0.09
2020-08-01 Elopement 0.00
2020-08-01 Self-injury 0.97
2020-09-01 Aggression 0.65
2020-09-01 Elopement 0.00
2020-09-01 Self-injury 1.58
2020-10-01 Aggression 0.24
2020-10-01 Elopement 0.00
2020-10-01 Self-injury 0.75
2020-11-01 Aggression 0.03
2020-11-01 Elopement 0.01
2020-11-01 Self-injury 0.89
2020-12-01 Aggression 0.14
2020-12-01 Elopement 0.00
2020-12-01 Self-injury 0.94
2021-01-01 Aggression 0.05
2021-01-01 Elopement 0.00
2021-01-01 Self-injury 0.30
2021-02-01 Self-injury 0.42
2021-02-01 Elopement 0.03
2021-02-01 Aggression 0.16
2021-03-01 Elopement 0.00
2021-03-01 Self-injury 0.68
2021-03-01 Aggression 0.20
2021-04-01 Aggression 0.10
2021-04-01 Elopement 0.03
2021-04-01 Self-injury 0.33
2021-05-01 Elopement 0.20
2021-05-01 Aggression 0.21
2021-05-01 Self-injury 1.63
2021-06-01 Self-injury 0.90
2021-06-01 Aggression 0.29
2021-06-01 Elopement 0.14

我发现这很奇怪,因为我直接遵循文档 - https://plotly.com/python/linear-fits/

这是一个已知问题吗?我无法通过谷歌搜索找到任何示例...

最佳答案

正如 Henry 有益地指出的,这只是一个版本问题,可以通过使用以下方法进行更新轻松解决:

pip install plotly==5.2.1

关于python - 类型错误 : scatter() got an unexpected keyword argument 'trendline_options' (Plotly, Python),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68808298/

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