If there a way that I can define filter in a variable, then use that variable to filter data frame or filter list?
For example, I can filter the list using code:
l = [1,2,3,4,5]
f = [i for i in l if i > 3]
f
Is there a way that I can define the filter in a variable? (the code below is not working)
ft = repr('if i > 3')
f_repr = [i for i in l eval(ft)]
f_repr