Skip to content

Commit b8267cb

Browse files
GH61405 Expose arguments in DataFrame.query
1 parent 0d96e9b commit b8267cb

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

pandas/core/frame.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4524,7 +4524,7 @@ def query(
45244524
self,
45254525
expr: str,
45264526
*,
4527-
parser: Literal["pandas", "python"] = ...,
4527+
parser: Literal["pandas", "python"] = "pandas",
45284528
engine: Literal["python", "numexpr"] | None = None,
45294529
local_dict: dict[str, Any] | None = None,
45304530
global_dict: dict[str, Any] | None = None,
@@ -4669,16 +4669,17 @@ def query(
46694669
msg = f"expr must be a string to be evaluated, {type(expr)} given"
46704670
raise ValueError(msg)
46714671

4672-
res = self.eval(
4673-
expr,
4674-
parser,
4675-
engine,
4676-
local_dict,
4677-
global_dict,
4678-
resolvers,
4679-
level + 1,
4680-
target,
4681-
)
4672+
kwargs = {
4673+
"parser": parser,
4674+
"engine": engine,
4675+
"local_dict": local_dict,
4676+
"global_dict": global_dict,
4677+
"resolvers": resolvers,
4678+
"level": level + 1,
4679+
"target": None,
4680+
}
4681+
4682+
res = self.eval(expr, **kwargs)
46824683

46834684
try:
46844685
result = self.loc[res]

0 commit comments

Comments
 (0)