Similar questions have been asked already but I still can't come up with a solution.
I have a pandas Dataframe of such a shape:
1 0 0 0 0
1 0 0 0 0
1 0 0 0 0
1 0 0 0 0
-1 0 0 0 0
-1 0 0 0 0
-1 0 0 0 0
-1 0 0 0 0
And I want to make it into one that looks like this:
1 1 0 0 0
1 0 1 0 0
1 0 0 1 0
1 0 0 0 1
-1 1 0 0 0
-1 0 1 0 0
-1 0 0 1 0
-1 0 0 0 1
I have tried np.fill_diagonal(df.values,1)
but that didn't work.