Skip to content Skip to sidebar Skip to footer

Parse Input And Structure The Output # Keywords From Tweets

I am trying to put all the #keywords from the tweetText into a separate column along with other columns. I have not mentioned other columns as they would only create confusion. Th

Solution 1:

Use python and regular expressions. It will make your life a lot easier. The regular expression r'#(\w+)'would work well in this instance.

I don't fully understand the flow of your code, since I don't have much experience with searching CSVs with panda, but if you were to isolate the tweet and return a string of the keywords/hashtags to that column by my understanding of conventional python logic, it might look something like this...

import re

for idx in range(len(tweet_column)):
    tweet = tweet_column[idx]
    hashtag_list = re.findall(r('#\w+)', tweet)
    tweet_column[idx] = " ".join(hashtag_list)

Here's another example

Post a Comment for "Parse Input And Structure The Output # Keywords From Tweets"