KeyError报错,list(b.index)的输出结果就是('ID_1',
'ID_2',
'ID_3',
'ID_4',
'ID_5',
'ID_6',
'ID_7',
'ID_8',
.)
问题相关代码:
response={}
u = [response[x] for x in list(b.index)]
报错结果如下
KeyError Traceback (most recent call last)
<ipython-input-30-e6944cc6404b> in <module>
1 response={}
----> 2 u = [response[x] for x in tuple(list(b.index))]
<ipython-input-30-e6944cc6404b> in <listcomp>(.0)
1 response={}
----> 2 u = [response[x] for x in tuple(list(b.index))]
KeyError: 'ID_1'