I have a condition for a pandas dataframe written in a string. Something like this:
\"(data[\'Variable1\'] == 1) & (data[\'Variable2\'] == 2)\"
You can use pandas query to filter required rows
your_query_string = "Variable1 == 1 & Variable2 == 2" data = data.query(your_query_string)