0

Data Farme

As we see in the Picture of my dataframe,

I have a data Frame with Column names "Actual Touches" and "Expected Touches"

Now I want to Value compare between the columns 'Actual Touches' and 'Expected Touches', taking base as 'Expected Touches' and assign the results to a third column named 'Results' (like if value in 'Actual Touches'== 'Expected Touches', then in the results column it should represent pass else fail.)

Thanks for your time,

Nevermore
  • 7,141
  • 5
  • 42
  • 64
Abhinayb
  • 11
  • 3
  • [Please not upload images of code or data on SO when asking a question](https://meta.stackoverflow.com/questions/285551/why-not-upload-images-of-code-on-so-when-asking-a-question) – anky May 20 '19 at 14:11
  • 1
    thanks for the info, I'm Kind of new to SO and its just my second question. – Abhinayb May 20 '19 at 14:13
  • bdw i think you can try `df['result']=np.where(df['Acutal Touches'].eq(df['Expected Touches']),'pass','fail')` – anky May 20 '19 at 14:16
  • 1
    Thanks a lot, appreciate your help.! – Abhinayb May 20 '19 at 14:22

1 Answers1

0

This will create a column called value in your dataframe stating whether or not value in Actual Touches and Expected Touches are equal.

df['value'] = df.apply(lambda x : True if x['Actual Touches'] == x['Expected Touches'] else False, axis=1)
Jules
  • 395
  • 4
  • 17