query in Python

From the Pandas cheat sheet ยท Filter and Query ยท verified Aug 2026

query

Filter with a readable expression string.

python
minimum = 90
high = df.query("score >= @minimum")
๐Ÿ’ก Prefix Python variables with @
๐Ÿ“Œ Column names become expression variables
โš ๏ธ Avoid untrusted input in query strings
๐Ÿ” Backticks escape columns with spaces
queryfilterexpressions

Continue with Pandas

Save the full cheat sheet or work through every related task.

More Python tasks

Back to the full Pandas cheat sheet