Pandas lookup from one of multiple columns, based on value
There is a built in lookup function that can handle this type of situation (looks up by row/column). I don’t know how optimized it is, but may be faster than the apply solution. In [9]: df[‘value’] = df.lookup(df.index, df[‘best’]) In [10]: df Out[10]: Date best a b c d value 0 1990 a 5 4 … Read more