结巴分词出现AttributeError: 'float' object has no attribute 'decode'错误

这个问题感觉很奇怪,报错的地方前后都没有数值,但就是报错。所以在读该文档的时候就将该dataframe格式转为str,就没有问题了
train = pd.read_csv("train.csv",encoding='utf-8',dtype=str)
train=train.astype(str)###################这个地方是解决方案
for index, row in train.iterrows():
words = jieba.cut(row['content'])
for word in words:
    print(word)
 
posted @ 2019-04-17 16:55  巴拉巴拉程序猿  Views(8981)  Comments(0Edit  收藏  举报