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 15:15:45 浏览: 65
这是一个 KeyError 错误,意味着你在尝试对一个不存在的列进行索引。在你的代码中,你试图使用 `undersampling_data[['type','amount','oldbalanceOrg','newbalanceOrig','oldbalanceDest','newbalanceDest']]` 来索引一个名为 `type` 的列,但是 `undersampling_data` 数据框中不存在 `type` 这个列。你需要检查一下你的数据框中是否存在名为 `type` 的列,或者使用适当的列名来进行索引。
相关问题
Traceback ( most recent call last ) :File " C:/python/kfc.py " , line 8
Traceback (most recent call last): File "C:/python/kfc.py", line 8
这是Python中的错误追踪信息,通常在程序出现错误时会显示。它告诉我们在哪个文件的哪一行出现了错误。
具体来说,"Traceback (most recent call last)" 表示错误追踪的开始,它告诉我们下面的信息是最近一次调用的错误。
"File "C:/python/kfc.py", line 8" 表示错误发生在文件 "C:/python/kfc.py" 的第8行。
如果你想解决这个错误,可以打开 "C:/python/kfc.py" 文件,并检查第8行的代码,看看是否有语法错误或逻辑错误。
Traceback (most recent call last): File "D:\代码文件夹\pythonProject\hello.py", line 95, in <module>
Traceback (most recent call last): File "D:\代码文件夹\pythonProject\hello.py", line 95, in <module> 是Python解释器在运行程序时遇到错误时输出的一种错误信息。它会显示出错的文件名、行号以及出错的代码行。在这个例子中,错误发生在文件 "D:\代码文件夹\pythonProject\hello.py" 的第95行。这意味着在该行的代码中出现了错误。
为了更好地理解和解决这个问题,我们需要查看该行代码的具体内容以及前面的上下文。请提供更多关于该行代码的信息,以便我能够给出更准确的回答。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pptx](https://img-home.csdnimg.cn/images/20210720083543.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)