Reputation: 21
-need your help, I have 10 conditions where if any 5 conditions are true then function will -shortlist those 5 and from that if any 3 conditions are true then function will validate:
con1 = check(df)
con2 = check2(df)
con3 = check3(df)
con4 = check4(df)
con5 = check5(df)
if ([con1 or con2 or con3 or con4 or con5]) == True:
then check if atleast 3 conditions are True:
if true:
print(df)
Upvotes: 2
Views: 521
Reputation: 19242
For checking whether at least 3 conditions are true, you can do:
if sum([cond1, cond2, cond3, cond4, cond5]) >= 3:
The sum()
function will treat True
as 1
and False
as 0
.
This assumes that all of the conditions are boolean values. See the comments for handling things like None
.
Upvotes: 4