【发布时间】:2022-01-03 01:27:51
【问题描述】:
我正在尝试使用 plotly 来构建折线图。这是我写的代码:
from fredapi import Fred
import plotly.express as px
fred = Fred("1c242ee90989c94ffb93c923d94e855f")
tran = pd.DataFrame(fred.get_series("EMISSCO2TOTVTCTOUSA"))
tran.columns = ["CO2"]
tran = tran.reset_index()
fig = px.line(tran, x = "index", y = "CO2")
fig.show()
为什么会出现以下错误:
AttributeError: 'object' 对象没有属性 'layout'
【问题讨论】:
-
请发布完整错误信息
-
我可以根据您的代码生成折线图。您使用的是什么版本的 Plotly?