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