简体   繁体   English

KeyError: "[Index(['file_path'], dtype='object')] 都不在 [columns] 中

[英]KeyError: "None of [Index(['file_path'], dtype='object')] are in the [columns]

I tried to run this file and it's giving me the following error while trying to call the function. I couldn't understand what is causing this error.我尝试运行此文件,但在尝试调用 function 时出现以下错误。我不明白是什么导致了此错误。 I want to do some image enhancement so that my model can better understand them while training.我想做一些图像增强,以便我的 model 在训练时可以更好地理解它们。 Any other suggestions or codes to do the same are welcome.欢迎任何其他建议或代码来做同样的事情。

Traceback (most recent call last):
  File "C:/DIP_Ankita/image_corrector.py", line 12, in <module>
    data = data[['file_path']]
  File "C:\Users\srchirag27\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas\core\frame.py", line 3001, in __getitem__
    indexer = self.loc._convert_to_indexer(key, axis=1, raise_missing=True)
  File "C:\Users\srchirag27\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas\core\indexing.py", line 1285, in _convert_to_indexer
    return self._get_listlike_indexer(obj, axis, **kwargs)[1]
  File "C:\Users\srchirag27\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas\core\indexing.py", line 1092, in _get_listlike_indexer
    keyarr, indexer, o._get_axis_number(axis), raise_missing=raise_missing
  File "C:\Users\srchirag27\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas\core\indexing.py", line 1177, in _validate_read_indexer
    key=key, axis=self.obj._get_axis_name(axis)
KeyError: "None of [Index(['file_path'], dtype='object')] are in the [columns]"

There was some issue with the file being saved.保存文件时出现问题。 The previously written code was being called rather than the updated one.调用的是以前编写的代码,而不是更新后的代码。 I deleted the file and then created another one with the same script and it worked fine.我删除了该文件,然后使用相同的脚本创建了另一个文件,并且运行良好。

data[['file_path']] creates a new dataframe containing only one column - file_path . data[['file_path']] 创建一个新的 dataframe 只包含一列 - file_path

Check data.columns and if the required column is not there then you need to ensure that column is being passed.检查 data.columns,如果所需的列不存在,则需要确保该列已被传递。

I think you are missing np before conj, np.conj() in your line 10我认为您在第 10 行中缺少 np before conj, np.conj()

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 IsolationForest KeyError:“[Index([''], dtype='object')] 均不在 [columns] 中” - IsolationForest KeyError: “None of [Index([''], dtype='object')] are in the [columns]” KeyError:“[Index([&#39;URL&#39;], dtype=&#39;object&#39;)] 都不在 [columns]”中 - KeyError: "None of [Index(['URL'], dtype='object')] are in the [columns]" 如何解决 KeyError:“[Index([&#39;t1&#39;], dtype=&#39;object&#39;)] 都不在 [columns]”中 - How To Solve KeyError: "None of [Index(['t1'], dtype='object')] are in the [columns]" KeyError:“[索引([('A','B','C')],dtype ='object')]都不在[列]中 - KeyError: "None of [Index([('A','B','C')] , dtype='object')] are in the [columns] 如何解决 KeyError:u“[Index([..], dtype='object')] 都不在 [columns] 中” - How To Solve KeyError: u"None of [Index([..], dtype='object')] are in the [columns]" 如何解决 KeyError:“[Index([..], dtype='object')] 均不在 [columns] 中”/KeyError(f"[{key}] 均不在 [{axis_name}] 中") - How To Solve KeyError: “None of [Index([..], dtype='object')] are in the [columns]”/KeyError(f"None of [{key}] are in the [{axis_name}]") KeyError:“[Index(['...', '...'], dtype='object')] 都不在 [index] 中” - KeyError: "None of [Index(['...', '...'], dtype='object')] are in the [index]" “ [Index([&#39;&#39;, &#39;&#39;], dtype=&#39;object&#39;)] 都不在 [columns] 中” - "None of [Index(['', ''], dtype='object')] are in the [columns]" KeyError: "[Index(['Zomba', 'Lilongwe', 'Blantyre', 'Mzuzu'], dtype='object')] 都不在 [columns] 中,我正在使用 Python Panda - KeyError: "None of [Index(['Zomba', 'Lilongwe', 'Blantyre', 'Mzuzu'], dtype='object')] are in the [columns]", I am using Python Panda KeyError:“[Index(['5', '22', '25', '12',..],\n dtype='object', length=610)] 均不在 [列] 中” - KeyError: “None of [Index(['5', '22', '25', '12',..],\n dtype='object', length=610)] are in the [columns]”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM