Consider a dataframe like:
df = pd.DataFrame({'r': [1, 1, 2, 2], 'c': [0, 2, 1, 2], 'v': [2, 4, 3, 5],})
I want to extract a numpy array or tensor considering 'r' and 'c' as row and column index of the matrix. so the corresponding matrix will be like:
arr = array([[0, 0, 0],
[2, 0, 4],
[0, 3, 5]])
So is there a decent way to do that or I have to loop through each df row? what about extracting dataframe df from a matrix like arr?