Traceback (most recent call last): File "C:\Users\14493\Desktop\pythonProject1\azhe.py", line 73, in <module> x_undersampling=undersampling_data[['type','amount','oldbalanceOrg','newbalanceOrig','oldbalanceDest','newbalanceDest']] File "C:\Users\14493\Desktop\pythonProject1\venv\lib\site-packages\pandas\core\frame.py", line 3767, in __getitem__ indexer = self.columns._get_indexer_strict(key, "columns")[1] File "C:\Users\14493\Desktop\pythonProject1\venv\lib\site-packages\pandas\core\indexes\base.py", line 5876, in _get_indexer_strict self._raise_if_missing(keyarr, indexer, axis_name) File "C:\Users\14493\Desktop\pythonProject1\venv\lib\site-packages\pandas\core\indexes\base.py", line 5938, in _raise_if_missing raise KeyError(f"{not_found} not in index") KeyError: "['type'] not in index"
时间: 2023-08-27 20:15:45 浏览: 162
Mac下anaconda中Spyder打开报错Traceback(most recent call last)…问题
5星 · 资源好评率100%
这是一个 KeyError 错误,意味着你在尝试对一个不存在的列进行索引。在你的代码中,你试图使用 `undersampling_data[['type','amount','oldbalanceOrg','newbalanceOrig','oldbalanceDest','newbalanceDest']]` 来索引一个名为 `type` 的列,但是 `undersampling_data` 数据框中不存在 `type` 这个列。你需要检查一下你的数据框中是否存在名为 `type` 的列,或者使用适当的列名来进行索引。
阅读全文