You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there a way to create string filter expressions and utilize them in .filter queries? (Similar to pandas df.query()) If not, what's the best way to go about this? Is 'eval' the recommended approach?
For eg.
filters = [("var1","==","10"), ("var2",">=","15")]
filter_expression = " & ".join([f"(_.{var} {operator} {value})" for var, operator, value in filters])
df = df.filter(eval(filter_expression))
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Is there a way to create string filter expressions and utilize them in .filter queries? (Similar to pandas df.query()) If not, what's the best way to go about this? Is 'eval' the recommended approach?
For eg.
Beta Was this translation helpful? Give feedback.
All reactions