我試圖將一條消息拆分為單獨的單詞,并嘗試對這些消息進行標記。def split_into_tokens(message): message = unicode(message, 'utf8') # convert bytes into proper unicode return TextBlob(message).wordsmessages.message.head().apply(split_into_tokens)如果顯示名稱錯誤:未定義名稱“unicode” <ipython-input-16-98e123c365b4> in <module>()----> 1 messages.title.head().apply(split_into_tokens)C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\series.py in apply(self, func, convert_dtype, args, **kwds) 3192 else: 3193 values = self.astype(object).values->3194 mapped = lib.map_infer(values, f, convert=convert_dtype) 3195 3196 if len(mapped) and isinstance(mapped[0], Series):pandas/_libs/src\inference.pyx in pandas._libs.lib.map_infer()<ipython-input-14-281c1d080655> in split_into_tokens(title) 1 def split_into_tokens(title):----> 2 title = unicode(title, utf8) # convert bytes into proper unicode 3 return TextBlob(title).wordsNameError: name 'unicode' is not defined最后它顯示未定義 unicode,我試圖更改 python 版本也仍然是同樣的問題。我是否需要在 python 插件目錄中用 str 替換 unicode ?
- 1 回答
- 0 關注
- 223 瀏覽
添加回答
舉報
0/150
提交
取消