For the following df
A B ..... THRESHOLD
DATE
2011-01-01 NaN NaN ..... NaN
2012-01-01 -0.041158 -0.161571 ..... 0.329038
2013-01-01 0.238156 0.525878 ..... 0.110370
2014-01-01 0.606738 0.854177 ..... -0.095147
2015-01-01 0.200166 0.385453 ..... 0.166235
I have to compare N number of columns like A,B,C .... with THRESHOLD and output the result like
df['A_CALC'] = np.where(df['A'] > df['THRESHOLD'], 1, -1)
df['B_CALC'] = np.where(df['B'] > df['THRESHOLD'], 1, -1)
How to apply the above for all columns (A,B,C ... ) without explicitly writing one statement per column ?