0

I am new to writing code and currently working on a project to compare two columns of an excel sheet using python and return the rows that does not match.

I tried using the .isin funtion and was able to identify output the values comparing the columns however i am not sure on how to print the actual row that returns the value "False"

For Example:

import pandas as pd
data = ["Darcy Hayward","Barbara Walters","Ruth Fraley","Minerva Ferguson","Tad Sharp","Lesley Fuller","Grayson Dolton","Fiona Ingram","Elise Dolton"]
df = pd.DataFrame(data, columns=['Names'])
df

enter image description here

data1 = ["Darcy Hayward","Barbara Walters","Ruth Fraley","Minerva Ferguson","Tad Sharp","Lesley Fuller","Grayson Dolton","Fiona Ingram"]
df1 = pd.DataFrame(data1, columns=['Names'])
df1

enter image description here

data_compare = df["Names"].isin(df1["Names"])
for data in data_compare:
    if data==False:
        print(data)

enter image description here

However, i want to know that 8 index returned False, something like the below format

enter image description here

Could you please advise how i can modify the code to get the output printed with the Index, Name that returned False?

0 Answers0