I have a Panda Dataframe with two columns (Word and Word_Position) in it. I need to find the distance between words and present the output in matrix form for better readability.
What I have done so far is I have created a row matrix from the DF.Word_Position column and transposed it to create a column matrix. When I subtracted both these matrices, I am getting few values with minus sign before them.
With all due respect to the great mathematics, this is absolutely correct but for my requirement I just need the number and not the minus sign.
Is there any other better way to do the same ? Appreciating your help. Thanks in advance.
Note : I am using Python 3.6
Code snippets and its corresponding output for your reference
m1 = np.matrix(df1['Word Position'])
print(m1)
[[ 1 2 3 ..., 19 20 21]]
m2 = np.matrix(m1.T)
print(m2)
[[ 1]
[ 2]
[ 3]
...,
[19]
[20]
[21]]
print(m2-m1)
[[ 0 -1 -2 ..., -18 -19 -20]
[ 1 0 -1 ..., -17 -18 -19]
[ 2 1 0 ..., -16 -17 -18]
...,
[ 18 17 16 ..., 0 -1 -2]
[ 19 18 17 ..., 1 0 -1]
[ 20 19 18 ..., 2 1 0]]