简体   繁体   English

两个数据集的python热图

[英]python heatmap for two datasets

Can someone tell me how to make a heatmap to see the correlation between each two variables from two datasets (with same rwo numbers but different column numbers). 有人可以告诉我如何制作一个热图,以查看来自两个数据集(具有相同的rwo号但具有不同的列号)的每个两个变量之间的相关性。 something like this: 像这样的东西:

dataset A: age length weight 数据集A:年龄长度权重

        2       5          7
        3       3          7
        6       9          2

dataset B: abcde 数据集B:abcde

        0.3    0.7     2.3    3.2    8.4
        5.2    3.2     3.4    1.1    0.4
        3.3    2.6     6.6    4.4    2.8

And the result heat map is like: 结果热图如下:

age 年龄

length (color cells here) 长度(此处为彩色单元格)

weight 重量

      a  b  c  d  e

I'm new in data visualization so thanks for any hint!! 我是数据可视化方面的新手,谢谢您的提示!!

Pandas already provides this functionality. 熊猫已经提供了此功能。 You can put the data in a dataframe then do this, first line to create the correlation matrix, second line to create a heatmap 您可以将数据放入数据帧中,然后执行此操作,第一行创建相关矩阵,第二行创建热图

corr=dataframe.corr()
corr.style.background_gradient()

background_style for pandas pandas correlation 熊猫关联的 background_style

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM