Problem: I have 2 Dataframes:
Name B Worker B A4 True A4 True A5 True AND A6 False A6 True C4 False A7 False C7 True I want to give out the "Name" where Df1.B == True and Df2.B == False
Check with isin
df1.loc[(df1.B)&(~df1.name.isin(df2.Worker)),'name'] Update
df1.loc[(df1.B)&(~df2.B),'name'] You could try this
Generate data
data1 = [['Name','B'],['A4',True],['A5',True],['A6',True],['A7',False]] data2 = [['Name','B'],['A4',True],['A6',False],['C4',False],['C7',True]] df1 = pd.DataFrame(data1[1:],columns=data1[0]) df2 = pd.DataFrame(data2[1:],columns=data2[0]) print(df1) Name B 0 A4 True 1 A5 True 2 A6 True 3 A7 False print(df2) Name B 0 A4 True 1 A6 False 2 C4 False 3 C7 True Filter
df1_filtered = df1.loc[(df1.B) & (~df2.B)] df2_filtered = df2.loc[(df1.B) & (~df2.B)] print(df1_filtered['Name']) 1 A5 2 A6 Name: Name, dtype: object print(df2_filtered['Name']) 1 A6 2 C4 Name: Name, dtype: object NOTE:
df1 then use df1_filtered. If you require output from df1, then use df2_filtered.