Trying to clean twitter data as a panda data frame. I seem to be missing a step. After I process all the the tweets, I think I am missing overwriting the new ones over old tweets? When I save the file, I see no changes in the tweets. What am I missing?
import pandas as pd
import re
import emoji
import nltk
nltk.download('words')
words = set(nltk.corpus.words.words())
trump_df = pd.read_csv('new_Trump.csv')
for tweet in trump_df['tweet']:
tweet = re.sub("@[A-Za-z0-9]+","",tweet) #Remove @ sign
tweet = re.sub(r"(?:\@|http?\://|https?\://|www)\S+", "", tweet) #Remove http links
tweet = " ".join(tweet.split())
tweet = ''.join(c for c in tweet if c not in emoji.UNICODE_EMOJI) #Remove Emojis
tweet = tweet.replace("#", "").replace("_", " ") #Remove hashtag sign but keep the text
tweet = " ".join(w for w in nltk.wordpunct_tokenize(tweet) \
if w.lower() in words or not w.isalpha()) #Remove non-english tweets (not 100% success)
print(tweet)
trump_df.to_csv('new_Trump.csv')