I have two dataframe: df1, df2
name gender
John 1
David 1
Lilly 0
Young 0
Lisa 0
Wang 1
name gender
Andy 1
Lilly 1
Wang 0
Mina 0
John 0
Claire 1
The two dataframes are both name-gender pair. I am trying to detect same names but assigned different gender in both dataframe(e.g., Lilly in df1 is assigned 0 and in df2 is assigned 1). I want to print a dataframe only shows that.
I used code
df2[df2[df1['name'] == df2['name'] and df2['gender'] != df1['gender']]
This code doesn't return an error but kept running forever. I wonder what did I do wrong. Is there any pandas command that can solve this?