Here's a simple function that deals with the case of all False is 'isValid' to still return the single bool True
def my_comp(df): u = df[df.isValid] if u.empty: return True else: return u['value1'].eq(u['value2']).all()my_comp(df1)#Truemy_comp(df2)#Truemy_comp(df3)#False