Python remove stop words from pandas dataframe

后端 未结 4 1348
走了就别回头了
走了就别回头了 2020-11-29 02:08

I want to remove the stop words from my column \"tweets\". How do I iterative over each row and each item?

pos_tweets = [(\'I love this car\', \'positive\'),         


        
4条回答
  •  囚心锁ツ
    2020-11-29 02:49

    If you would like something simple but not get back a list of words:

    test["tweet"].apply(lambda words: ' '.join(word.lower() for word in words.split() if word not in stop))
    

    Where stop is defined as OP did.

    from nltk.corpus import stopwords
    stop = stopwords.words('english')
    

提交回复
热议问题