0

I have a DataFrame that looks something like this.

    Column 1    Column 2    Column 3
0   ABC           1         Sunny
1   EFG           2         Rainy
2   HIJ           3         Cloudy
3   KLM           4         Thunder

I now want to use filtering with multiple conditions, and I know that if filtering with a given condition can be done with this statement.

df[df["Cloumn 1"] == "ABC" & other conditions]

But this is not flexible enough, my user may use only one condition this time or add another condition, and may want to use <= such a comparison character, if in the code to write dead conditions, then it is very inconvenient when encountering this method.

How can I write filtering code with uncertain number and format of conditions? (Like WHERE Cloumn_1 = 'ABC', Cloumn_2 = '2' in a SQL query statement)

Syni
  • 11
  • 1
  • 5
  • You may try pandas [`query`](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.query.html) but provide specific example input and desired output to get an appropriate reply from the community. – SomeDude Sep 21 '22 at 06:19

0 Answers0