我正在尝试从 UNESCO 数据 api 下载一个表格并将其转换为 pandas DataFrame。到目前为止,我已经到了这么远:
from pandasdmx import Request as rq
auth = {'Ocp-Apim-Subscription-Key': '...'}
uis = rq('unesco', headers = auth)
uis_resp = uis.get(resource_type = 'data',
resource_id = 'RD',
url = 'https://api.uis.unesco.org/sdmx//data/UNESCO,'
+ 'RD'
+ ',1.0/',
params = {'key': '.CAP_PPP_CONST...........',
'format': 'sdmx-generic-2.1',
'subscription-key' : '...'})
uis_data = uis_resp.data
uis_iter = (s for s in uis_data.series) # Creating an iterator from the Series
data = uis_resp.write(list(uis_iter)) # Creating a dataframe
不幸的是,它给了我以下错误:
data = uis_resp.write(list(uis_iter)) # Creating a dataframe
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-2-db0f6c589a91> in <module>()
----> 1 data = uis_resp.write(list(uis_iter)) # Creating a dataframe
C:\Users\andras\Anaconda3\lib\site-packages\pandaSDMX-0.7.0-py3.6.egg\pandasdmx\api.py in write(self, source, **kwargs)
633 if not source:
634 source = self.msg
--> 635 return self._writer.write(source=source, **kwargs)
636
637 def write_source(self, filename):
C:\Users\andras\Anaconda3\lib\site-packages\pandaSDMX-0.7.0-py3.6.egg\pandasdmx\writer\data2pandas.py in write(self, source, asframe, dtype, attributes, reverse_obs, fromfreq, parse_time)
114 pd_series, pd_attributes = zip(*series_list)
115 elif dtype:
--> 116 key_fields = series_list[0].name._fields
117 pd_series = series_list
118 elif attributes:
IndexError: list index out of range
关于我做错了什么的任何想法?