240 发简信
IP属地:广东
  • 你好,楼主,data['cut'] = data['comment'].apply(lambda x : list(jieba.cut(x)))在处理的时候会出现
    KeyError Traceback (most recent call last)
    ~\anaconda3\lib\site-packages\pandas\core\indexes\base.py in get_loc(self, key, method, tolerance)
    2894 try:
    -> 2895 return self._engine.get_loc(casted_key)
    2896 except KeyError as err:

    pandas\_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc()

    pandas\_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc()

    pandas\_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

    pandas\_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

    KeyError: 'comment'

    The above exception was the direct cause of the following exception:

    KeyError Traceback (most recent call last)
    <ipython-input-16-7ac7c3a0d336> in <module>
    ----> 1 data['cut'] = data['comment'].apply(lambda x : list(jieba.cut(x)))

    ~\anaconda3\lib\site-packages\pandas\core\frame.py in __getitem__(self, key)
    2900 if self.columns.nlevels > 1:
    2901 return self._getitem_multilevel(key)
    -> 2902 indexer = self.columns.get_loc(key)
    2903 if is_integer(indexer):
    2904 indexer = [indexer]

    ~\anaconda3\lib\site-packages\pandas\core\indexes\base.py in get_loc(self, key, method, tolerance)
    2895 return self._engine.get_loc(casted_key)
    2896 except KeyError as err:
    -> 2897 raise KeyError(key) from err
    2898
    2899 if tolerance is not None:

    KeyError: 'comment'
    是什么问题

    Python中文分词及词频统计

    中文分词 中文分词(Chinese Word Segmentation),将中文语句切割成单独的词组。英文使用空格来分开每个单词的,而中文单独一个汉字跟词有时候完全不是同个含...

  • 老师,想咨询下,我想输出的不是词云图,是输出成统计各个词出现频次的饼图,可以怎么操作

    如何用Python做词云?

    临渊羡鱼,不如退而结网。我们步步为营,从头开始帮助你用Python做出第一张词云图来。欢迎尝试哦! 在大数据时代,你经常可以在媒体或者网站上看到一些非常漂亮的信息图。 例如这...