In [1]:
import scikit_posthocs as sp
import numpy as np
import pandas as pd

Without p adjustments


In [2]:
x = [[1,2,3,5,1], [12,31,54], [10,12,6,74,11]]
sp.posthoc_conover(x)


Out[2]:
array([[ -1.00000000e+00,   3.98391078e-04,   1.39164426e-03],
       [  3.98391078e-04,  -1.00000000e+00,   1.86722274e-01],
       [  1.39164426e-03,   1.86722274e-01,  -1.00000000e+00]])

With Holm p adjustment


In [3]:
sp.posthoc_conover(x, p_adjust = 'holm')


Out[3]:
array([[-1.        ,  0.00119517,  0.00278329],
       [ 0.00119517, -1.        ,  0.18672227],
       [ 0.00278329,  0.18672227, -1.        ]])

Exporting to pandas


In [4]:
groups = [['a']*5, ['b']*3, ['c']*5]
df = pd.DataFrame({'vals': np.concatenate(x), 'groups': np.concatenate(groups)})
df


Out[4]:
groups vals
0 a 1
1 a 2
2 a 3
3 a 5
4 a 1
5 b 12
6 b 31
7 b 54
8 c 10
9 c 12
10 c 6
11 c 74
12 c 11

In [5]:
result = sp.posthoc_conover(df, val_col='vals', group_col='groups')
result


Out[5]:
a b c
a -1.000000 0.000398 0.001392
b 0.000398 -1.000000 0.186722
c 0.001392 0.186722 -1.000000