Skip to content

Instantly share code, notes, and snippets.

@dominiquesydow
Created April 20, 2022 06:52
Show Gist options
  • Save dominiquesydow/5300d3caf2605932464a30c5ef124130 to your computer and use it in GitHub Desktop.
Save dominiquesydow/5300d3caf2605932464a30c5ef124130 to your computer and use it in GitHub Desktop.
Filter rows in pandas with query()
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@baoilleach
Copy link

Good to know. Though I do prefer if there's just one way to do something, even if clunky. Does it still work if there's a space in the name?

@dominiquesydow
Copy link
Author

If the column name "a" was called "a a", the query would look like this:

df.query("`a a` < 4 and c < 4")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment