Given the example table
df = pd.DataFrame({'A':[8,4,8,4,9],'Ap':[0.001,0.06,0.001,0.1,0.002],'B':[7,3,9,3,6],
'Bp':[0.005,0.006,0.01,0.007,0.06],'C':[4,1,4,8,9],
'Cp':[0.004,0.008,0.2,0.006,0.00001]}, index=['x','y','z','zz','yz'])
That looks like this:
A Ap B Bp C Cp
x 8 0.001 7 0.005 4 0.00400
y 4 0.060 3 0.006 1 0.00800
z 8 0.001 9 0.010 4 0.20000
zz 4 0.100 3 0.007 8 0.00600
yz 9 0.002 6 0.060 9 0.00001
I'd like the keep/record the row value for the column with the lowest value from (A,B,C)
new = pd.DataFrame()
new['Minimum'] = df[[df.columns[0],df.columns[2],df.columns[4]]].min(axis=1)
This result will look like this
Minimum
x 4
y 1
z 4
zz 3
yz 6
But I'd also like to record the pval associated with the minimum value kept (Ap, Bp, Cp) and I'm unsure how to accomplish that.
So for example the final result should look like this
Minimum pVal
x 4 0.004
y 1 0.008
z 4 0.200
zz 3 0.007
yz 6 0.060