I have two row columns in my Pandas set
name1 name2
John Doe John Doe
AleX T Franz K
and I need to check if it is equal name1 name2. The naive way I'm using now is to use a simple mask
mask=df.name1==df.name2
But the problem is that lines can be labeled (in a sense that are not predictable - too much data) that prevents an exact match.
For example, "John Doe" and "John Doe" do not match. Of course, I cut, lowered my strings, but other possibilities remain.
One idea would be to see if name1c name2. But it looks like I cannot use str.containswith another variable as an argument. Any other ideas?
Many thanks!
EDIT: isin .
test = pd.DataFrame({'A': ["john doe", " john doe", 'John'], 'B': [' john doe', 'eddie murphy', 'batman']})
test
Out[6]:
A B
0 john doe john doe
1 john doe eddie murphy
2 John batman
test['A'].isin(test['B'])
Out[7]:
0 False
1 True
2 False
Name: A, dtype: bool