我正在尝试创建一个新列,其中包含数据框中的 clean_word
列的 pos 标记。此列包含单个单词,如下图所示。因此不需要标记化等。
下面是我的代码。
import nltk
datahitword['pos_tag'] = nltk.pos_tag(datahitword['clean_word'])
datahitword.head()
即使将列转换为列表和系列以单独处理它然后添加到数据框后,我仍收到以下错误。
TypeError: argument of type 'float' is not iterable
我在这里缺少什么吗?
最佳答案
正如@alvas 推荐的那样。只需要将单词转换为字符串即可
datahitword['clean_word'] = datahitword['clean_word'].astype(str)
关于python - 使用 NLTK 的数据集行的 POS 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46636047/