I am trying to make changes to each string in my Series object 'tweet_text', but for some reason when I print the series object after making changes to the tweets in my for loop, I get the same strings as I had before the for loop. How can I fix this?
import pandas as pd
import re
import string
df = pd.read_csv('sample-tweets.csv',
names=['Tweet_Date', 'User_ID', 'Tweet_Text', 'Favorites', 'Retweets', 'Tweet_ID'])
sum_df = df[['User_ID', 'Tweet_ID', 'Tweet_Text']].copy()
sum_df.set_index(['User_ID'])
# print sum_df
tweet_text = df.ix[:, 2]
print type(tweet_text)
# efficiency could be im proved by using translate method
# regex = re.compile('[%s]' % re.escape(string.punctuation))
for tweet in tweet_text:
tweet = re.sub('https://t.co/[a-zA-Z0-9]*', "", tweet)
tweet = re.sub('@[a-zA-Z0-9]*', '', tweet)
tweet = re.sub('#[a-zA-Z0-9]*', '', tweet)
tweet = re.sub('$[a-zA-Z0-9]*', '', tweet)
tweet = ''.join(i for i in tweet if not i.isdigit())
tweet = tweet.replace('"', '')
tweet = re.sub(r'[\(\[].*?[\)\]]', '', tweet) # takes out everything between parentheses also, fix this
# gets rid of all punctuation and emoji's
tweet = "".join(l for l in tweet if l not in string.punctuation)
tweet = re.sub(r'[^\x00-\x7F]+',' ', tweet)
# gets ride of all extra spacing
tweet = tweet.lower()
tweet = tweet.strip()
tweet = " ".join(tweet.split())
count = count + 1
# print tweet
print tweet_text