get matrix diagonal python code example Example: numpy get diagonal matrix from matrix np.diag(np.diag(x))