Traceback (most recent call last):
File "D:\Softwares\Python3.6.8\lib\site-packages\pandas\core\indexes\base.py", line 2646, in get_loc
    return self._engine.get_loc(key)
File "pandas\_libs\index.pyx", line 111, in pandas._libs.index.IndexEngine.get_loc
File "pandas\_libs\index.pyx", line 138, in pandas._libs.index.IndexEngine.get_loc
File "pandas\_libs\hashtable_class_helper.pxi", line 1619, in pandas._libs.hashtable.PyObjectHashTable.get_item
File "pandas\_libs\hashtable_class_helper.pxi", line 1627, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'xxx'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "d:\Codes\Python_proj\pandas_excel\XXX.py", line 16, in <module>
    not_at_school_notfinish = not_at_school_notfinish.loc[data['xxx']]
File "D:\Softwares\Python3.6.8\lib\site-packages\pandas\core\frame.py", line 2800, in __getitem__
    indexer = self.columns.get_loc(key)
File "D:\Softwares\Python3.6.8\lib\site-packages\pandas\core\indexes\base.py", line 2648, in get_loc
    return self._engine.get_loc(self._maybe_cast_indexer(key))
File "pandas\_libs\index.pyx", line 111, in pandas._libs.index.IndexEngine.get_loc
File "pandas\_libs\index.pyx", line 138, in pandas._libs.index.IndexEngine.get_loc
File "pandas\_libs\hashtable_class_helper.pxi", line 1619, in pandas._libs.hashtable.PyObjectHashTable.get_item
File "pandas\_libs\hashtable_class_helper.pxi", line 1627, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'xxx'

解决办法

可能是对原始文件进行了排序,导致找不到列名

相关文章:

  • 2021-07-31
  • 2022-12-23
  • 2022-12-23
  • 2021-07-03
  • 2022-12-23
  • 2021-04-09
  • 2022-12-23
猜你喜欢
  • 2021-07-05
  • 2021-08-20
  • 2022-01-04
  • 2022-12-23
  • 2022-12-23
  • 2023-01-17
  • 2021-05-23
相关资源
相似解决方案