How to find ngram frequency of a column in a pandas dataframe?
<p>Below is the input pandas dataframe I have.</p>

<p><a href="https://i.stack.imgur.com/ltSrD.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ltSrD.png" alt="enter image description here"></a></p>

<p>I want to find the frequency of unigrams &amp; bigrams. A sample of what I am expecting is shown below<a href="https://i.stack.imgur.com/7NOKk.png" rel="noreferrer"><img src="https://i.stack.imgur.com/7NOKk.png" alt="enter image description here"></a></p>

<p>How to do this using nltk or scikit learn?</p>

<p>I wrote the below code which takes a string as input. How to extend it to series/dataframe?</p>

<pre><code>from nltk.collocations import *
desc='john is a guy person you him guy person you him'
tokens = nltk.word_tokenize(desc)
bigram_measures = nltk.collocations.BigramAssocMeasures()
finder = BigramCollocationFinder.from_words(tokens)
finder.ngram_fd.viewitems()
</code></pre>