Skip to content

Commit 183a50f

Browse files
GH61405 Expose arguments in DataFrame.query
1 parent b8267cb commit 183a50f

File tree

1 file changed

+37
-7
lines changed

1 file changed

+37
-7
lines changed

pandas/core/frame.py

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4486,7 +4486,6 @@ def query(
44864486
global_dict: dict[str, Any] | None = ...,
44874487
resolvers: list[Mapping] | None = ...,
44884488
level: int = ...,
4489-
target: None = ...,
44904489
inplace: Literal[False] = ...,
44914490
) -> DataFrame: ...
44924491

@@ -4501,7 +4500,6 @@ def query(
45014500
global_dict: dict[str, Any] | None = ...,
45024501
resolvers: list[Mapping] | None = ...,
45034502
level: int = ...,
4504-
target: None = ...,
45054503
inplace: Literal[True],
45064504
) -> None: ...
45074505

@@ -4516,7 +4514,6 @@ def query(
45164514
global_dict: dict[str, Any] | None = ...,
45174515
resolvers: list[Mapping] | None = ...,
45184516
level: int = ...,
4519-
target: None = ...,
45204517
inplace: bool = ...,
45214518
) -> DataFrame | None: ...
45224519

@@ -4530,7 +4527,6 @@ def query(
45304527
global_dict: dict[str, Any] | None = None,
45314528
resolvers: list[Mapping] | None = None,
45324529
level: int = 0,
4533-
target: None = None,
45344530
inplace: bool = False,
45354531
) -> DataFrame | None:
45364532
"""
@@ -4551,11 +4547,45 @@ def query(
45514547
45524548
See the documentation for :meth:`DataFrame.eval` for details on
45534549
referring to column names and variables in the query string.
4550+
parser : {'pandas', 'python'}, default 'pandas'
4551+
The parser to use to construct the syntax tree from the expression. The
4552+
default of ``'pandas'`` parses code slightly different than standard
4553+
Python. Alternatively, you can parse an expression using the
4554+
``'python'`` parser to retain strict Python semantics. See the
4555+
:ref:`enhancing performance <enhancingperf.eval>` documentation for
4556+
more details.
4557+
engine : {'python', 'numexpr'}, default 'numexpr'
4558+
4559+
The engine used to evaluate the expression. Supported engines are
4560+
4561+
- None : tries to use ``numexpr``, falls back to ``python``
4562+
- ``'numexpr'`` : This default engine evaluates pandas objects using
4563+
numexpr for large speed ups in complex expressions with large frames.
4564+
- ``'python'`` : Performs operations as if you had ``eval``'d in top
4565+
level python. This engine is generally not that useful.
4566+
4567+
More backends may be available in the future.
4568+
local_dict : dict or None, optional
4569+
A dictionary of local variables, taken from locals() by default.
4570+
global_dict : dict or None, optional
4571+
A dictionary of global variables, taken from globals() by default.
4572+
resolvers : list of dict-like or None, optional
4573+
A list of objects implementing the ``__getitem__`` special method that
4574+
you can use to inject an additional collection of namespaces to use for
4575+
variable lookup. For example, this is used in the
4576+
:meth:`~DataFrame.query` method to inject the
4577+
``DataFrame.index`` and ``DataFrame.columns``
4578+
variables that refer to their respective :class:`~pandas.DataFrame`
4579+
instance attributes.
4580+
level : int, optional
4581+
The number of prior stack frames to traverse and add to the current
4582+
scope. Most users will **not** need to change this parameter.
4583+
inplace : bool, default False
4584+
If `target` is provided, and the expression mutates `target`, whether
4585+
to modify `target` inplace. Otherwise, return a copy of `target` with
4586+
the mutation.
45544587
inplace : bool
45554588
Whether to modify the DataFrame rather than creating a new one.
4556-
**kwargs
4557-
See the documentation for :func:`eval` for complete details
4558-
on the keyword arguments accepted by :meth:`DataFrame.query`.
45594589
45604590
Returns
45614591
-------

0 commit comments

Comments
 (0)