I am trying to count the frequency of hashtag words in the 'text' column of my dataframe.
index text
1 ello ello ello ello #hello #ello
2 red green blue black #colours
3 Season greetings #hello #goodbye
4 morning #goodMorning #hello
5 my favourite animal #dog
word_freq = df.text.str.split(expand=True).stack().value_counts()
The above code will perform a frequency count on all strings in the text column, but I just to return the hashtag frequencies.
For example after running the code on my dataframe above, it should return
#hello 3
#goodbye 1
#goodMorning 1
#ello 1
#colours 1
#dog 1
Is there a way of slightly re-jigging my word_freq code so it only counts hashtag words and returns them in the way I put above? Thanks in advance.