How Can I Enlarge The Below Output In Python Because Want To Use It As An Input Somewhere Else?
This is the code that I am using: ho = ho.replace('((www\.[\s]+)|(https?://[^\s]+))','URL',regex=True) ho =ho.replace(r'#([^\s]+)', r'\1', regex=True) ho =ho.replace('\''',regex
Solution 1:
I think you need str.split
for list of all words - it split by all whitespaces - also need ho['tweet']
for select column tweet
:
wordList = word_tokenize(fg)
#output isstring
ho1=ho['tweet'].str.split()
.apply(lambda x:' '.join([word for word in wordList if word not in eng_stopwords]))
Or:
wordList = word_tokenize(fg)
#output is list
ho1=ho['tweet'].str.split()
.apply(lambda x:[word for word in wordList if word notin eng_stopwords])
instead:
ho = ho.to_frame(name=None)
a=ho.to_string(buf=None, columns=None, col_space=None, header=True,
index=True, na_rep='NaN', formatters=None, float_format=None,
sparsify=False, index_names=True, justify=None, line_width=None,
max_rows=None, max_cols=None, show_dimensions=False)
wordList = word_tokenize(fg)
wordList = [word for word in wordList if word notin eng_stopwords]
print (wordList)
Post a Comment for "How Can I Enlarge The Below Output In Python Because Want To Use It As An Input Somewhere Else?"