I have created a matrix in dataframe to compare words and have converted it to numpy using "penaltymatrix = np.array(df.values)". How do I convert the rows and columns also?
The top part is the numpy array and the second part is the pandas dataframe which includes the appropiate column & row names.
Code:
def computeTable():
sampInput = file1()
refInput = file2()
sampString = [word.strip(string.punctuation).lower() for word in sampInput.split()]
refString = [word.strip(string.punctuation).lower() for word in refInput.split()]
df = pd.DataFrame(index=sampString, columns=refString)
penaltymatrix = np.array(df.values)
penaltymatrix[0, 0] = 0
print(penaltymatrix)
print(3*"\n")
print(df)