I have a bunch of data stored in a DataFrame. I am trying to allows users to pass in query criteria in the form of:
column, operator, variable_name
So a user might pass in the following as an example
'Action equal allow,total_bytes > 10000,application neq facebook'
I parse that string by splitting and formatting into a query string that looks like this
query_string = (dframe['Action'] == 'allow') & (dframe['total_bytes'] > 10000) & ~(dframe[''Application] == 'facebook')
Then, I attempt to create a filtered table to return to the user by passing in the query_string I parsed the inputs to get.
dframe_filtered = dframe[query_string]
However this fails with a key error - I think because Python needs to see the query_string as not really a string - but Pandas series. Is there a way to make this work? Not sure you describe having Python not parse text as a string. But hopefully you all take the meaning.
Thanks!
df.queryand take the user input in that format?