将两种方法合二为一 table 的相关性 table

Correlation table with two methods in one table

我喜欢创建一个包含两个相关系数的相关性 table。 (皮尔逊和斯皮尔曼)

我知道我可以用 df.corr(method='spearman') 创建一个关联 table。

您知道同一个 table 是否可能包含 'pearson' 和 'spearman' 系数吗? 就像皮尔逊在括号中的斯皮尔曼系数下面。

谢谢

例如:

不漂亮,但可能是这样的:

df = pd.DataFrame(np.random.rand(3,3))                                                
c1 = df.corr()                                                                        
c2 = df.corr(method='spearman')                                                       
corr_df = c1.applymap(lambda x: [x]) + c2.applymap(lambda x: [x])

输出:

                            0                            1                            2
0                  [1.0, 1.0]    [0.5457412669991152, 0.5]   [-0.533894951027147, -0.5]
1   [0.5457412669991152, 0.5]                   [1.0, 1.0]  [-0.9999009746183144, -1.0]
2  [-0.533894951027147, -0.5]  [-0.9999009746183144, -1.0]                   [1.0, 1.0]