Skip to content

Instantly share code, notes, and snippets.

@sid321axn
Created August 3, 2020 12:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sid321axn/bf22950e71e204af401623807d706187 to your computer and use it in GitHub Desktop.
Save sid321axn/bf22950e71e204af401623807d706187 to your computer and use it in GitHub Desktop.
from nltk.corpus import stopwords
stop = set(stopwords.words('english'))
punctuation = list(string.punctuation)
stop.update(punctuation)
# Removing stop words which are unneccesary from headline news
def remove_stopwords(text):
final_text = []
for i in text.split():
if i.strip().lower() not in stop:
final_text.append(i.strip())
return " ".join(final_text)
df['title']=df['title'].apply(remove_stopwords)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment