【发布时间】:2021-10-18 19:52:08
【问题描述】:
我收到了错误:
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/
这是一个已知问题吗?我找不到任何用谷歌搜索的例子......
【问题讨论】:
-
OLS Parameters 是“v5.2 中的新功能”。此代码在当前任何受支持的版本(5.2.0 或 5.2.1)中都不会引发此错误
-
你说得对,完全是一个版本的东西......好地方!谢谢。
标签: python pandas graph plotly trendline