I'm not sure about your true / false conditions, but I think you need something similar, thanks @JohnGalt:
df.apply(lambda x: ((1 - x/x.max()) > 0.05).all())
Or using your logic:
df.apply(lambda x: ((x[x.idxmax()]-x)/x[x.idxmax()]*100>5).all())
Output:
TSLA False MSFT False dtype: bool
Let's look at one column,
Formula John:
1 - df.TSLA/df.TSLA.max()
Return:
2017-05-15 00:00:00+00:00 0.000000 2017-05-16 00:00:00+00:00 0.003125 2017-05-17 00:00:00+00:00 0.018750 2017-05-18 00:00:00+00:00 0.021875 2017-05-19 00:00:00+00:00 0.012500 2017-05-22 00:00:00+00:00 0.018750 2017-05-23 00:00:00+00:00 0.031250 Name: TSLA, dtype: float64
If all of these values ββare greater than 5, return True, else return False.
My original formula also works, just a little more calculation to do the same thing as John's formula. Finally, use the lambda function to apply this formula to each column independently.
source share