Srini
Srini

Reputation: 97

Export Correlation Heatmap to Excel

I am trying to export my correlation heatmap to excel. I can't find any documentation/syntax on this by python


corr.style.background_gradient(cmap='coolwarm').set_precision(2)

corr.style. \
    apply(background_gradient, axis=None).\
    to_excel("mev_corr_matrix.xlsx", engine="openpyxl")



I want to export the heatmap as is to excel

Upvotes: 2

Views: 2463

Answers (1)

jezrael
jezrael

Reputation: 862601

You can chain both code together with .:

(corr.style.background_gradient(cmap='coolwarm')
           .to_excel("mev_corr_matrix.xlsx", engine="openpyxl"))

If need change precision:

(corr.style.background_gradient(cmap='coolwarm')
           .set_precision(2)
           .to_excel("mev_corr_matrix.xlsx", engine="openpyxl"))

Upvotes: 5

Related Questions