I have a dataframe V
of the following form:
ECON1 ECON2 ECON3 FOOD1 FOOD2 FOOD3 ENV1 \
28 0.310071 0.096913 0.228500 0.234986 0.260894 0.267858 0.489309
28 0.353609 0.045075 0.222571 0.222803 0.248388 0.330560 0.060107
28 0.280600 0.170201 0.232027 0.226792 0.233379 0.316765 0.114550
28 0.299062 0.127866 0.198080 0.189948 0.222982 0.327082 0.052881
28 0.346291 0.645534 0.371397 0.389068 0.380557 0.386004 0.186583
ENV2 HEA1 HEA2 HEA3 PERS1 PERS2 PERS3 \
28 0.206320 0.252537 0.266968 0.248452 0.184450 0.093345 0.173952
28 -0.206570 0.263673 0.126182 0.265908 0.134481 0.191341 0.113324
28 0.237818 0.257337 0.102037 0.214423 0.159002 0.321451 0.165960
28 0.345857 0.272412 0.069192 0.251301 0.130606 0.132732 0.174925
28 0.372713 0.382155 0.373531 0.468293 0.364305 0.299510 0.350822
COM1 COM2 POL1 POL2
28 0.781430 0.487822 0.361886 0.233124
28 0.083918 0.005381 0.266604 0.237078
28 0.395897 0.257888 0.330607 0.229079
28 0.000000 0.000000 0.307907 0.238908
28 0.188402 0.101147 0.410619 0.385933
I am trying to do a correlation analysis as follows:
import seaborn as sb
corr = V.corr()
ax = sb.heatmap(
corr,
vmin=-1, vmax=1, center=0,
cmap=sb.diverging_palette(20, 220, n=200),
square=True
)
ax.set_xticklabels(
ax.get_xticklabels(),
rotation=45,
horizontalalignment='right'
);
I get an error as follows:
TypeError: 'float' object cannot be interpreted as an integer
Not sure how to interpret this error. Can someone comment on this please?
additional information on the correlation matrix
print(corr)
ECON1 ECON2 ECON3 FOOD1 FOOD2 FOOD3 ENV1 \
ECON1 1.000000 0.341774 0.498779 0.522529 0.588714 0.503961 -0.074569
ECON2 0.341774 1.000000 0.964742 0.951770 0.932538 0.785570 0.003878
ECON3 0.498779 0.964742 1.000000 0.998125 0.983827 0.734790 0.104750
FOOD1 0.522529 0.951770 0.998125 1.000000 0.991068 0.703027 0.153686
FOOD2 0.588714 0.932538 0.983827 0.991068 1.000000 0.683437 0.192360
FOOD3 0.503961 0.785570 0.734790 0.703027 0.683437 1.000000 -0.580854
ENV1 -0.074569 0.003878 0.104750 0.153686 0.192360 -0.580854 1.000000
ENV2 -0.475257 0.564601 0.369804 0.349462 0.328092 0.202113 0.183099
HEA1 0.518089 0.971623 0.948098 0.938049 0.941533 0.857258 -0.087292
HEA2 0.492331 0.760587 0.854620 0.882823 0.909930 0.320175 0.579590
HEA3 0.637159 0.933654 0.949112 0.949667 0.970425 0.798348 0.014684
PERS1 0.435383 0.965742 0.986036 0.988420 0.983967 0.656593 0.222572
PERS2 0.006943 0.584600 0.574856 0.535135 0.424989 0.647732 -0.423388
PERS3 0.278137 0.981872 0.931251 0.923784 0.918289 0.687020 0.134177
COM1 -0.323141 -0.151890 -0.047608 -0.009682 -0.018765 -0.702210 0.913371
COM2 -0.405013 -0.141136 -0.060505 -0.026537 -0.041302 -0.702745 0.897211
POL1 0.024764 0.819855 0.797155 0.804438 0.792430 0.291577 0.526974
POL2 0.534160 0.974790 0.970808 0.965523 0.969961 0.813307 -0.000965
ENV2 HEA1 HEA2 HEA3 PERS1 PERS2 PERS3 \
ECON1 -0.475257 0.518089 0.492331 0.637159 0.435383 0.006943 0.278137
ECON2 0.564601 0.971623 0.760587 0.933654 0.965742 0.584600 0.981872
ECON3 0.369804 0.948098 0.854620 0.949112 0.986036 0.574856 0.931251
FOOD1 0.349462 0.938049 0.882823 0.949667 0.988420 0.535135 0.923784
FOOD2 0.328092 0.941533 0.909930 0.970425 0.983967 0.424989 0.918289
FOOD3 0.202113 0.857258 0.320175 0.798348 0.656593 0.647732 0.687020
ENV1 0.183099 -0.087292 0.579590 0.014684 0.222572 -0.423388 0.134177
ENV2 1.000000 0.440689 0.309514 0.335610 0.473824 0.161769 0.664619
HEA1 0.440689 1.000000 0.738058 0.982913 0.938014 0.492595 0.945905
HEA2 0.309514 0.738058 1.000000 0.811820 0.901376 0.157842 0.801182
HEA3 0.335610 0.982913 0.811820 1.000000 0.942849 0.387558 0.915053
PERS1 0.473824 0.938014 0.901376 0.942849 1.000000 0.472608 0.963744
PERS2 0.161769 0.492595 0.157842 0.387558 0.472608 1.000000 0.447905
PERS3 0.664619 0.945905 0.801182 0.915053 0.963744 0.447905 1.000000
COM1 0.106662 -0.304509 0.362041 -0.239231 0.040733 -0.226292 -0.058492
COM2 0.185397 -0.307438 0.332330 -0.257903 0.034155 -0.208413 -0.041872
POL1 0.727061 0.707109 0.856765 0.695222 0.875352 0.297894 0.887691
POL2 0.424788 0.995079 0.798982 0.989886 0.965114 0.480057 0.953595
COM1 COM2 POL1 POL2
ECON1 -0.323141 -0.405013 0.024764 0.534160
ECON2 -0.151890 -0.141136 0.819855 0.974790
ECON3 -0.047608 -0.060505 0.797155 0.970808
FOOD1 -0.009682 -0.026537 0.804438 0.965523
FOOD2 -0.018765 -0.041302 0.792430 0.969961
FOOD3 -0.702210 -0.702745 0.291577 0.813307
ENV1 0.913371 0.897211 0.526974 -0.000965
ENV2 0.106662 0.185397 0.727061 0.424788
HEA1 -0.304509 -0.307438 0.707109 0.995079
HEA2 0.362041 0.332330 0.856765 0.798982
HEA3 -0.239231 -0.257903 0.695222 0.989886
PERS1 0.040733 0.034155 0.875352 0.965114
PERS2 -0.226292 -0.208413 0.297894 0.480057
PERS3 -0.058492 -0.041872 0.887691 0.953595
COM1 1.000000 0.995152 0.397261 -0.217775
COM2 0.995152 1.000000 0.419501 -0.225367
POL1 0.397261 0.419501 1.000000 0.748706
POL2 -0.217775 -0.225367 0.748706 1.000000
You might want to look into this issue: https://github.com/mwaskom/seaborn/issues/1907
The issue seems to come from
cmap=sns.diverging_palette(20, 220, n=200),
You might need to update your seaborn installationWorks just fine for me.
Dataframe:
Correlation matrix
Plot: