fixed diagonalize code to new version of pandas