英文:
hasattr(): attribute name must be string
问题
I am trying to make a stacked bar plot in plotly using webscraping. However, I keep getting this error: "hasattr(): attribute name must be string". I think it might be the part: "gdp['IMF[1][13]', 'Estimate']" that is causing the error.
This is what the dataframe looks like:
enter image description here
import plotly.express as px
ERROR -> fig = px.bar(gdp, x = gdp['UN Region'], y = gdp['IMF[1][13]', 'Estimate'], color = gdp['Country/Territory'])
fig.show()
英文:
I am trying to make a stacked bar plot in plotly using webscraping. However, I keep getting this error: "hasattr(): attribute name must be string". I think it might be the part:"gdp['IMF[1][13]', 'Estimate']" that is causing the error.
This is what the dataframe looks like:
enter image description here
import plotly.express as px
ERROR -> fig = px.bar(gdp, x = gdp['UN Region'], y = gdp['IMF[1][13]', 'Estimate'], color = gdp['Country/Territory'])
fig.show()
答案1
得分: 0
尝试:
fig = px.bar(gdp, x = gdp['UN Region', 'UN Region'],
y = gdp['IMF[1][13]', 'Estimate'],
color = gdp['Country/Territory', 'Country/Territory'])
英文:
Try:
fig = px.bar(gdp, x = gdp['UN Region', 'UN Region'],
y = gdp['IMF[1][13]', 'Estimate'],
color = gdp['Country/Territory', 'Country/Territory'])
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论