import numpy as np
mat = np.array([
[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
])
def get_diag_mat(mat):
rows, cols = mat.shape
assert rows == cols, "Matrix isn't square"
new_mat = np.zeros(mat.shape)
for i in range(rows):
new_mat[i][rows-i-1] = mat[i][rows-i-1]
return new_mat
print(get_diag_mat(mat))