“pandasdmx”文档有一个如何设置维度的示例,但没有如何设置属性。我尝试将“key”传递给变量,但出现错误。也许设置属性需要不同的语法?在示例代码的末尾,我打印了一个维度和属性列表。
import pandasdmx as sdmx
import pandas as pd
ecb = sdmx.Request('ECB')
key = dict(FREQ=['M'], SEC_ITEM=['F51100'], REF_AREA = ['I8'], SEC_ISSUING_SECTOR = ['1000'])
params = dict(startPeriod='2010-02', endPeriod='2010-02')
data_msg = ecb.data('SEC', key=key, params=params)
data = data_msg.data[0]
daily = [s for sk, s in data.series.items() if sk.FREQ == 'M']
cur_df = pd.concat(sdmx.to_pandas(daily)).unstack()
print(cur_df.to_string())
flow_msg = ecb.dataflow()
dataflows = sdmx.to_pandas(flow_msg.dataflow)
exr_msg = ecb.dataflow('SEC')
exr_flow = exr_msg.dataflow.SEC
dsd = exr_flow.structure
dimen = dsd.dimensions.components
attrib = dsd.attributes.components
print(dimen)
print(attrib)