I have a dataframe like this:
data = [[1, 0, 1],
[1, 1, 1],
[0, 0, 1]]
df = pd.DataFrame(data=data, columns=['col1', 'col2', 'col3'])
and from a string like this:
cond_str = ['col1 >= 1', 'col3 >= 1']
and I would like to achieve this:
df.loc[(df['col1'] >= 1) & (df['col3'] >= 1)]
Is there any simple way to do this or do I have to write my own parsing function for this?
cond_strlist indf.loc[(df['col1'] >= 1) & (df['col3'] >= 1)]with some modification?