I am trying to color points of an pandas dataframe dependend on TWO conditions. Example:
If value of col1 > a (float) AND value of col2- value of col3 < b (float), then value of col 4 = string, else: other string.
I have tried so many different ways now and everything I found online was only depending on one condition.
My example code always raises the Error: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
Here's the code. Tried several variations without success.
df = pd.DataFrame()
df['A'] = range(10)
df['B'] = range(11,21,1)
df['C'] = range(20,10,-1)
borderE = 3.
ex = 0.
#print df
df['color'] = np.where(all([df.A < borderE, df.B - df.C < ex]), 'r', 'b')
Btw: I understand, what it says but not how to handle it... Thanks in advance!