Reputation: 67
I like to create one correlation table which contains two correlation coefficents. (pearson and spearman)
I know that I can create with df.corr(method='spearman') a correlation table.
Do you know if it's possible that the same table contains the 'pearson' and 'spearman' coefficent? Like the pearson is underneath the spearman coefficent in brackets.
Thank you
For example:
Upvotes: 1
Views: 110
Reputation: 3280
Not pretty, but maybe something along these lines:
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])
Output:
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]
Upvotes: 2