The original dataframe is a table like this:
S1_r1_ctrl/ S1_r2_ctrl/ S1_r3_ctrl/
sp|P38646|GRP75_HUMAN 2.960000e-06 5.680000e-06 0.000000e+00
sp|O75694-2|NU155_HUMAN 2.710000e-07 0.000000e+00 2.180000e-07
sp|Q05397-2|FAK1_HUMAN 0.000000e+00 2.380000e-07 7.330000e-06
sp|O60671-2|RAD1_HUMAN NaN NaN NaN
I am looking for the smallest value in each column of a dataframe greater than zero. I was trying to use this example to answer my question. My code looks like:
df.ne(0).idxmin().to_frame('pos').assign(value=lambda d: df.lookup(d.pos, d.index))
but still I get only zeros and my result looks like this:
pos value
S1_r1_ctrl/ sp|Q05397-2|FAK1_HUMAN 0.0
S1_r2_ctrl/ sp|O75694-2|NU155_HUMAN 0.0
S1_r3_ctrl/ sp|P38646|GRP75_HUMAN 0.0
instead of this:
pos value
S1_r1_ctrl/ sp|O75694-2|NU155_HUMAN 2.710000e-07
S1_r2_ctrl/ sp|Q05397-2|FAK1_HUMAN 2.380000e-07
S1_r3_ctrl/ sp|O75694-2|NU155_HUMAN 2.180000e-07
I guess there might be a problem in data types but I'm not sure. I assumed ne(0)
would ignore zeros but it doesn't so I am confused why. And perhaps there's a more intelligent way to find what I need.