Python 将相关热图导出到Excel

Python 将相关热图导出到Excel,python,python-3.x,pandas,jupyter,correlation,Python,Python 3.x,Pandas,Jupyter,Correlation,我正在尝试将我的相关热图导出到excel。我找不到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 hea

我正在尝试将我的相关热图导出到excel。我找不到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

您可以使用
将这两个代码链接在一起:

(corr.style.background_gradient(cmap='coolwarm')
           .to_excel("mev_corr_matrix.xlsx", engine="openpyxl"))
如果需要更改:

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