wie man die Hauptdiagonale in Pandas verändert
import numpy as np
s = pd.Series(data=[1,2,3],index=['a','b','c'])
df = pd.DataFrame(0, index=s.index, columns=s.index, dtype=s.dtype)
np.fill_diagonal(df.values, s)#you can also make s to be just a single float
print (df)
a b c
a 1 0 0
b 0 2 0
c 0 0 3
Eilay Koren