使用安然数据集时出现关键错误(没有dict值)

2024-10-04 01:30:38 发布

您现在位置:Python中文网/ 问答频道 /正文

import pandas as pd
enrond_dataframe = pd.DataFrame(final_embeddings)
enrond_dataframe = enrond_dataframe.set_index([ reverse_dictionary.values()])
enrond_dataframe.head()

我得到的错误如下

KeyError                                  Traceback (most recent call last)
<ipython-input-4-0328d6643879> in <module>
      1 import pandas as pd
      2 enrond_dataframe = pd.DataFrame(final_embeddings)
----> 3 enrond_dataframe = enrond_dataframe.set_index([ reverse_dictionary.values()])
      4 enrond_dataframe.head()

~/anaconda3/lib/python3.7/site-packages/pandas/core/frame.py in set_index(self, keys, drop, append, inplace, verify_integrity)
   4301 
   4302         if missing:
-> 4303             raise KeyError(f"None of {missing} are in the columns")
   4304 
   4305         if inplace:

KeyError: "None of [dict_values(['UNK', 'the', 'ect', 'to', 'enron', 'hou', 'and', 'a', 'of', 'on', 'you', 'i',...


我在上面也得到了一个关键错误,但我用 词汇表(字典) 打印('字典大小',len(字典)) 在word2vec的setp2的最后步骤中


Tags: ofinimportdataframepandasindex字典as