pandas.DataFrame.query
pandas 3.1.1 · DataFrame · method
Filter DataFrame rows using a trusted expression over columns or the index. Use @name to reference a local variable.
Call syntax
DataFrame.query(…) Full signature
DataFrame.query(
expr,
*,
parser='pandas',
engine=None,
local_dict=None,
global_dict=None,
resolvers=None,
level=0,
inplace=…,
)Run the example
Edit the example and select Run Python to see the result.
Parameters
| Parameter | Requirement | Accepted values and behavior |
|---|---|---|
expr |
Required Positional or keyword |
str Provide the expression evaluated by pandas. |
parser |
Optional Keyword only Default 'pandas' |
{'pandas', 'python'} |
engine |
Optional Keyword only Default None |
{'python', 'numexpr'} Choose the implementation that performs the operation. |
local_dict |
Optional Keyword only Default None |
dict or None Provide local variable bindings available to the expression. |
global_dict |
Optional Keyword only Default None |
dict or None Provide global variable bindings available to the expression. |
resolvers |
Optional Keyword only Default None |
list of dict-like or None Provide objects used to resolve names in an expression. |
level |
Optional Keyword only Default 0 |
int Choose an index level by name or integer position. |
inplace |
Optional Keyword only |
bool Choose whether to change the existing object. Where supported, an in-place call typically returns None. |
Returns
DataFrame or None