0
df1 = 
Profit, Qualified 
1000, TRUE 
2000, FALSE 
3000, FALSE 
4000, TRUE

Desired output:

df1= 
Profit, Qualified, Qualified Profit 
1000, TRUE, 1000 
2000, FALSE, 0 
3000, FALSE, 0 
4000, TRUE, 4000

Two lines of code i have tried:

df1['Qualified Profit'] = df1['Profit'].where(df1['Qualified'] == "TRUE")

df1['Qualified Profit'] = df1.apply(lambda x: x['Profit'] if x["Qualified"]=="TRUE" else '0', axis=1)
Wondercricket
  • 7,651
  • 2
  • 39
  • 58
Hedge_hog
  • 13
  • 3

0 Answers0