Say I have a dataframe in Pandas consisting of several columns. I would like to select the subset of the dataframe where all columns are between two values min
and max
.
How can I do this using query
? Do I need to specify every column name one by one in the expression e.g.:
df.query('(A<{max} & A>{min}) & (B{min} & B{max}) & (C{min} & C{max})'.format(min,max))
Aside from query, what other alternatives do I have? Perhaps working with the indices where the condition is met directly?