用 PANDAS 或 Plotly 绘制 SDMX 数据的最简单方法是什么?
我有以下代码:
import pandasdmx as sdmx
import plotly.express as px
df = sdmx.Request('OECD').data(
resource_id='MEI_FIN',
key='IR3TIB.GBR+USA.M',
params={'startTime': '1900-06', 'dimensionAtObservation': 'TimeDimension'},
).write().reset_index()
df
我在尝试绘图时最终收到以下错误
fig = px.line(df, x="TIME_PERIOD", y='', title='Life expectancy in Country: Denmark')
fig.show()
如下:
ValueError: Value of 'y' is not the name of a column in 'data_frame'. Expected one of `[('TIME_PERIOD', '', ''), ('IR3TIB', 'GBR', 'M'), ('IR3TIB', 'USA', 'M')] but received:`
我对 python 很陌生,所以我会感谢每一个可以帮助我的评论。