0
votes

I have the following two columns in my df.i want to filter on these columns in such a way that the resulting df after the filter should be like the below resultant df.

input Table

col1 col2
null Approved
FALSE null
null null
FALSE Approved
TRUE null
null new
FALSE Declined
FALSE new

output result Table after filter

col1 col2
null Approved
null null
**FALSE Approved**
TRUE null
null new

LOGIC - if col1 is False then col2 should be Approved, OR col1 should not be equal to FALSE.

1

1 Answers

0
votes

You may use where on your df

df.where("""
 (
    col1='FALSE' AND 
    col2='Approved'
 ) OR
 col1 <> 'FALSE'
""")

or

df.where(
    (
        (df.col1 == 'FALSE') &
        (df.col2 == 'Approved')
    ) 
    | 
    (df.col1 != 'FALSE')
)

NB. we use & for and and | for or