0

I have a data-frame :

df1 = pd.DataFrame({'col1': [1000, 10000, -100], 'col2': [-5,10000, 200 ]})

I would like two conditions: if (col1 * col2) < 0 and abs(col2 – col1) > 1000 then ‘Target’, else ‘No’ So the result could be:

enter image description here

How can I do it without having to create supportive columns?

toerag
  • 49
  • 3
  • Use `df['col3'] = np.where( (df.col1 * df.col2 < 0) & (abs(df.col2 - df.col1) > 1000), 'Target', 'No' )` – jezrael Sep 21 '22 at 12:31

0 Answers0