jeudi 11 novembre 2021

Python to use multiple conditions on 2 data frames and output the outlier

Hi I have 2 data frames with multiple columns but just showing relevant columns only:

df1:

Column A

CharlesBarkley

Michael Jordan

df2:

Column A / Column B

charles barkley / Yes

MichaelJordan / No

I want to achieve the following:

  1. I want to first compare df1's Column A to df2's Column A ignoring the space and case-sensitive and making everything lower-case with no space (so it can be michaeljordan).

  2. If Column B says No, I want to create a new column and output only the rows that the name matches AND having 'No' for Column B on df2, with the word 'Not Registered' in Python print as follows:

Column A / Result

michaeljordan / Not Registered

How would I be able to achieve this with the Python code?

Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire