I am very new to Python. I have a list of tuples, where I created bigrams.
This question is pretty close to my needs
my_list = [('we', 'consider'), ('what', 'to'), ('use', 'the'), ('words', 'of')]
Now I am trying to convert this into a frequency matrix
The desired output is
consider of the to use we what words
consider 0 0 0 0 0 0 0 0
of 0 0 0 0 0 0 0 0
the 0 0 0 0 0 0 0 0
to 0 0 0 0 0 0 0 0
use 0 0 1 0 0 0 0 0
we 1 0 0 0 0 0 0 0
what 0 0 0 1 0 0 0 0
words 0 1 0 0 0 0 0 0
How to do this, using numpy
or pandas
? I can see something with nltk
only, unfortunately.