![](/img/trans.png)
[英]AttributeError: module 'plotly.express' has no attribute 'Constant'
[英]AttributeError: module 'plotly.express' has no attribute 'sunburst'
AttributeError:模塊“plotly.express”沒有屬性“sunburst”
我的錯誤代碼:
import plotly.express as px
import numpy as np
df = px.data.gapminder().query("year == 1957")
fig = px.sunburst(df, path=['continent', 'country'], values='pop',
color='gdpPercap', hover_data=['iso_alpha'],
color_continuous_scale='gdpPercap',
color_continuous_midpoint=np.average(df['gdpPercap'], weights=df['pop']))
fig.show()
錯誤信息:
AttributeError Traceback (most recent call last
<ipython-input-25-228e1998d41a> in <module>()
2 import numpy as np
3 df = px.data.gapminder().query("year == 1957")
----> 4 fig = px.sunburst(df, path=['continent', 'country'], values='pop',
5 color='gdpPercap', hover_data=['iso_alpha'],
6 color_continuous_scale='gdpPercap', ```
AttributeError: module 'plotly.express' has no attribute 'sunburst'
sunburst
是在plotly的4.4.0版本中添加的,所以如果你有之前的版本需要更新模塊
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.