TF = (Number of times term T appears in the particular row) / (number of terms in that row)

Below, tried to show the term frequency table of a comment_text.

5.3 Inverse Document Frequency

The intuition behind inverse document frequency (IDF) is that a word is not of much use to if it’s appearing in all the documents. IDF = log(N/n) where, N is the total number of rows and n is the number of rows in which the word was present. So, calculate IDF for the same comment_text for which we calculated the term frequency.Here, more the value of IDF, means that more unique is the word.