« first day (2034 days earlier)      last day (1322 days later) » 

raf
6:14 PM
def cleaning(text):                     # kaggle.com/alankritamishra/…
    '''Make text lowercase, remove text in square brackets, remove links, remove punctuation, remove stopwords,
    and remove words containing numbers.'''
    text = text.lower()
    text = re.sub('\[.*?\]', '', text)
    text = re.sub('https?://\S+|www\.\S+', '', text)
    text = re.sub('<.*?>+', '', text)
    text = re.sub('[%s]' % re.escape(string.punctuation), '', text)
I wanna apply it on the column named 'text' in this dataframe (Kaggle link).
My target is to find the top N most frequent words from the column 'text'.
 
raf
6:52 PM
stop_words = stopwords.words()

def cleaning(text):                     # kaggle.com/alankritamishra/…
    '''Make text lowercase, remove text in square brackets, remove links, remove punctuation,
    and remove words containing numbers.'''
    text = text.lower()
    text = re.sub('\[.*?\]', '', text)
    text = re.sub('https?://\S+|www\.\S+', '', text)
    text = re.sub('<.*?>+', '', text)
    text = re.sub('[%s]' % re.escape(string.punctuation), '', text)
 
1 message moved from Python
3 messages moved from Python
 
 
2 hours later…
8:54 PM
arent closures valid in python ? ibb.co/WxqJPsq
what else can I do to use subs?
ahh, strings work but the docs do not tell that
 

« first day (2034 days earlier)      last day (1322 days later) »