0

I need to create a new column that compares 2 other column values in the same row. If they are the same, the new column would say yes and if not the same, say no. Something like below. if the amount of Pears and Bananas is the same, the column "Same Amount?" would say yes; otherwise no.

Person     Apples   Bananas Pears   Same Amount?
Richard      1          3     5        no
Irene        1          5     4        no
Chloe        5          7     7        yes
Priscialla   8          4     11       no
Evelyn       9          7     7        yes
Robin        5          5     5        yes
miradulo
  • 28,857
  • 6
  • 80
  • 93
Richard
  • 23
  • 1
  • 8
  • `df['Same Amount?'] = np.where(df.Pears == df.Bananas, 'yes', 'no')` – cs95 May 05 '18 at 21:06
  • I did not see this and did not know it was a duplicate but thank you for your help. It worked. Much appreciated. – Richard May 06 '18 at 01:07

0 Answers0