2023-01-15

How to check one rows value present in any of the other column row value

I have excel like below

A B
1A 100 
2A  1A 
3A  101
5A  1A  

Expected out is

A B   Bool
1A 100  
2A  1A  True
3A  101 
5A  1A   True

Here you can see that 1A present in df['A'] is present in df['B]

I tried like

import pandas as pd
df = pdf.read_excel('test.xlsx')
df['A'].isin(df['B']) 

but its not working



No comments:

Post a Comment