I have a pandas data-frame consist of Topic-Name,Description
I am trying to convert it into Topic-Name, Word (appeared in Description Column) and its Frequency
I have tried this but it only gave me word and frequency for Descriptions, not on Topic-Name Level.
import nltk
top_N = 4
a = df['ParsedText'].str.cat(sep=' ')
nltk.download('punkt')
words = nltk.tokenize.word_tokenize(a)
word_dist = nltk.FreqDist(words)
rslt = pd.DataFrame(word_dist.most_common(top_N),
columns=['Word', 'Frequency'])
print(rslt)
- Parsed Text is a Description Column

