Hi I am trying to replace all the expressions containing 'www...' and 'http://..' with just 'URL'. I tried this but I am getting this error.
TypeError: expected string or buffer
My code is:
df['text_1'] = re.sub('((www\.[^\s]+)|(https?://[^\s]+))','URL',df['text'])
df[text]
contains tweets, so I want to keep only the text in there.
I am in Python 2
Thanks.
df[text]
a list of tweets, i.e. a list of strings, or a single string? Have you tried... = [re.sub('<regex>','URL',s) for s in df['text']]
?df[text]
there is one tweet. This is what are you asking?df
actually is. We know it's not a string and not a buffer, I'm assuming it's a pandas DataFrame.