Sparse matrix in pandas/scipy with row and column indices I have a dataframe in pandas that looks like this: