I have a condition for a pandas dataframe written in a string. Something like this:
"(data['Variable1'] == 1) & (data['Variable2'] == 2)"
Is there a way to apply this condition without using eval() function?
Expected result:
data = data[(data['Variable1'] == 1) & (data['Variable2'] == 2)]