return self._engine.get_loc(casted_key) File "pandas\_libs\index.pyx", line 70, in pandas._libs.index.IndexEngine.get_loc File "pandas\_libs\index.pyx", line 101, in pandas._libs.index.IndexEngine.get_loc File "pandas\_libs\hashtable_class_helper.pxi", line 1675, in pandas._libs.hashtable.PyObjectHashTable.get_item File "pandas\_libs\hashtable_class_helper.pxi", line 1683, in pandas._libs.hashtable.PyObjectHashTable.get_item KeyError: 'pre' The above exception was the direct cause of the following exception: Traceback (most recent call last): File "C:/Users/DELL/Desktop/python_flask-dc/python_flask/bpnn_tf.py", line 108, in <module> cf['pre'] = cf['pre'].astype(str) File "E:\python-3.7.0\lib\site-packages\pandas\core\frame.py", line 2906, in __getitem__ indexer = self.columns.get_loc(key) File "E:\python-3.7.0\lib\site-packages\pandas\core\indexes\base.py", line 2900, in get_loc raise KeyError(key) from err KeyError: 'pre'
时间: 2023-10-06 12:06:44 浏览: 474
Python小白逆袭大神:Day3练习和作业代码
这个错误的意思是在Pandas DataFrame中找不到名为"pre"的列。请检查输入的DataFrame是否包含名为"pre"的列。您可以使用 `print(df.columns)` 打印DataFrame的所有列名以检查是否存在名为"pre"的列。另外,请确保输入的列名正确无误,并且没有引入任何拼写错误。
阅读全文