TypeError:序列项0:预期的str实例,找到列表

时间:2019-03-19 11:37:12

标签: python text-mining

我需要您的帮助,我正在进行文本挖掘,文本分类,并且当我要将单词列表转换为字符串时,因为countvec不能与列表一起使用,所以我报错

    Data['FilteredArticle']=0.0
    for i in range (0,Data.shape[0]):
        DS=nlp(Data['Titre-Article'][i])
        Data['FilteredArticle'][i]=[ w for w in DS if w.is_alpha and not w.is_stop and not w.is_punct and len(w)>3] 
    from sklearn.model_selection import train_test_split
    X_train, X_valid, y_train, y_valid = train_test_split(Data.FilteredArticle , Data.classe)
    Xtrain=" ".join(X_train)
    count_vect = CountVectorizer(analyzer='word', token_pattern=r'\w{1,}')
    count_vect.fit(X_train)

TypeError跟踪(最近一次通话)  在 ----> 1 Xtrain =“” .join(X_train)

TypeError:序列项0:预期的str实例,找到列表enter image description here

0 个答案:

没有答案