- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
如果我们有三个数据集:
X = pd.DataFrame({"t":[1,2,3,4,5],"A":[34,12,78,84,26], "B":[54,87,35,25,82], "C":[56,78,0,14,13], "D":[0,23,72,56,14], "E":[78,12,31,0,34]})
Y = pd.DataFrame({"t":[1,2,3,4,5],"A":[45,24,65,65,65], "B":[45,87,65,52,12], "C":[98,52,32,32,12], "D":[0,23,1,365,53], "E":[24,12,65,3,65]})
Z = pd.DataFrame({"t":[1,2,3,4,5],"A":[14,96,25,2,25], "B":[47,7,5,58,34], "C":[85,45,65,53,53], "D":[3,35,12,56,236], "E":[68,10,45,46,85]})
其中“t”是一个索引。
只是轴看起来像这样:
最佳答案
X = pd.DataFrame({"t":[1,2,3,4,5],"A":[34,12,78,84,26], "B":[54,87,35,25,82], "C":[56,78,0,14,13], "D":[0,23,72,56,14], "E":[78,12,31,0,34]})
Y = pd.DataFrame({"t":[1,2,3,4,5],"A":[45,24,65,65,65], "B":[45,87,65,52,12], "C":[98,52,32,32,12], "D":[0,23,1,365,53], "E":[24,12,65,3,65]})
Z = pd.DataFrame({"t":[1,2,3,4,5],"A":[14,96,25,2,25], "B":[47,7,5,58,34], "C":[85,45,65,53,53], "D":[3,35,12,56,236], "E":[68,10,45,46,85]})
catted = pd.concat([d.set_index('t') for d in [X, Y, Z]], axis=1, keys=['X', 'Y', 'Z'])
catted = catted.rename_axis(['Source', 'Column'], axis=1)
corrmat = catted.corr()
f, ax = plt.subplots()
sns.heatmap(corrmat, vmax=.8, square=True)
sources = corrmat.columns.get_level_values(0)
for i, source in enumerate(sources):
if i and source != sources[i - 1]:
ax.axhline(len(sources) - i, c="w")
ax.axvline(i, c="w")
f.tight_layout()
对评论的回应:
我更改了 X
、Y
和 Z
t
列
X = pd.DataFrame({"t":[1,2,3,4,5],"A":[34,12,78,84,26], "B":[54,87,35,25,82], "C":[56,78,0,14,13], "D":[0,23,72,56,14], "E":[78,12,31,0,34]})
Y = pd.DataFrame({"t":[6,7,8,9,10],"A":[45,24,65,65,65], "B":[45,87,65,52,12], "C":[98,52,32,32,12], "D":[0,23,1,365,53], "E":[24,12,65,3,65]})
Z = pd.DataFrame({"t":[11,12,13,14,15],"A":[14,96,25,2,25], "B":[47,7,5,58,34], "C":[85,45,65,53,53], "D":[3,35,12,56,236], "E":[68,10,45,46,85]})
catted = pd.concat([d.set_index('t') for d in [X, Y, Z]], axis=1, keys=['X', 'Y', 'Z'])
catted = catted.rename_axis(['Source', 'Column'], axis=1)
corrmat = catted.corr()
f, ax = plt.subplots()
sns.heatmap(corrmat, vmax=.8, square=True)
sources = corrmat.columns.get_level_values(0)
for i, source in enumerate(sources):
if i and source != sources[i - 1]:
ax.axhline(len(sources) - i, c="w")
ax.axvline(i, c="w")
f.tight_layout()
现在又来了,不过我reset_index
X = pd.DataFrame({"t":[1,2,3,4,5],"A":[34,12,78,84,26], "B":[54,87,35,25,82], "C":[56,78,0,14,13], "D":[0,23,72,56,14], "E":[78,12,31,0,34]})
Y = pd.DataFrame({"t":[6,7,8,9,10],"A":[45,24,65,65,65], "B":[45,87,65,52,12], "C":[98,52,32,32,12], "D":[0,23,1,365,53], "E":[24,12,65,3,65]})
Z = pd.DataFrame({"t":[11,12,13,14,15],"A":[14,96,25,2,25], "B":[47,7,5,58,34], "C":[85,45,65,53,53], "D":[3,35,12,56,236], "E":[68,10,45,46,85]})
catted = pd.concat([d.reset_index(drop=True) for d in [X, Y, Z]], axis=1, keys=['X', 'Y', 'Z'])
catted = catted.rename_axis(['Source', 'Column'], axis=1)
corrmat = catted.corr()
f, ax = plt.subplots()
sns.heatmap(corrmat, vmax=.8, square=True)
sources = corrmat.columns.get_level_values(0)
for i, source in enumerate(sources):
if i and source != sources[i - 1]:
ax.axhline(len(sources) - i, c="w")
ax.axvline(i, c="w")
f.tight_layout()
关于python - 具有匹配列的多个数据集的相关矩阵热图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41019902/
我想要类似于以下伪代码的东西: while input is not None and timer = 5: print "took too long" else: print inp
如何将 MainEngine Observable 转换为 Cold?来自这个例子: public IObservable MainEngine { get
自从手表被发明以来,表盘的方圆之争就始终没有停下来过,在漫长的岁月中,无论是方形还是圆形表盘,人们都为其寻找到足够多的设计元素,让其肆意成长,这种生机与活力后来也延续到了智能手表上,在2014年,这
我正在学习 CUDA,试图解决一些标准问题。例如,我正在使用以下代码求解二维扩散方程。但我的结果与标准结果不同,我无法弄清楚。 //kernel definition __global__ void
我的 Web 应用程序使用 native dll 来实现其部分功能(其位置在 PATH 中提供)。一切正常,直到我对 WAR 进行更改并且 JBoss 热部署此 WAR。此时dll已经找不到了,需要手
我看到这个问题here 。这是关于实现每个发出的项目的延迟。这是根据accepted answer如何实现的: Observable.zip(Observable.range(1, 5) .g
我最近一直在进行冷迁移...这意味着我无法在进行迁移时从应用程序级别读取/写入数据库(维护页面)。 这样就不会因为更改结构而发生错误,而且如果负载很大,我也不希望 mysql 在迁移过程中崩溃。 我的
我是一名优秀的程序员,十分优秀!