@@ -4477,18 +4477,62 @@ def _get_item(self, item: Hashable) -> Series:
4477
4477
4478
4478
@overload
4479
4479
def query (
4480
- self , expr : str , * , inplace : Literal [False ] = ..., ** kwargs
4480
+ self ,
4481
+ expr : str ,
4482
+ * ,
4483
+ parser : Literal ["pandas" , "python" ] = ...,
4484
+ engine : Literal ["python" , "numexpr" ] | None = ...,
4485
+ local_dict : dict [str , Any ] | None = ...,
4486
+ global_dict : dict [str , Any ] | None = ...,
4487
+ resolvers : list [Mapping ] | None = ...,
4488
+ level : int = ...,
4489
+ target : None = ...,
4490
+ inplace : Literal [False ] = ...,
4481
4491
) -> DataFrame : ...
4482
4492
4483
4493
@overload
4484
- def query (self , expr : str , * , inplace : Literal [True ], ** kwargs ) -> None : ...
4494
+ def query (
4495
+ self ,
4496
+ expr : str ,
4497
+ * ,
4498
+ parser : Literal ["pandas" , "python" ] = ...,
4499
+ engine : Literal ["python" , "numexpr" ] | None = ...,
4500
+ local_dict : dict [str , Any ] | None = ...,
4501
+ global_dict : dict [str , Any ] | None = ...,
4502
+ resolvers : list [Mapping ] | None = ...,
4503
+ level : int = ...,
4504
+ target : None = ...,
4505
+ inplace : Literal [True ],
4506
+ ) -> None : ...
4485
4507
4486
4508
@overload
4487
4509
def query (
4488
- self , expr : str , * , inplace : bool = ..., ** kwargs
4510
+ self ,
4511
+ expr : str ,
4512
+ * ,
4513
+ parser : Literal ["pandas" , "python" ] = ...,
4514
+ engine : Literal ["python" , "numexpr" ] | None = ...,
4515
+ local_dict : dict [str , Any ] | None = ...,
4516
+ global_dict : dict [str , Any ] | None = ...,
4517
+ resolvers : list [Mapping ] | None = ...,
4518
+ level : int = ...,
4519
+ target : None = ...,
4520
+ inplace : bool = ...,
4489
4521
) -> DataFrame | None : ...
4490
4522
4491
- def query (self , expr : str , * , inplace : bool = False , ** kwargs ) -> DataFrame | None :
4523
+ def query (
4524
+ self ,
4525
+ expr : str ,
4526
+ * ,
4527
+ parser : Literal ["pandas" , "python" ] = ...,
4528
+ engine : Literal ["python" , "numexpr" ] | None = None ,
4529
+ local_dict : dict [str , Any ] | None = None ,
4530
+ global_dict : dict [str , Any ] | None = None ,
4531
+ resolvers : list [Mapping ] | None = None ,
4532
+ level : int = 0 ,
4533
+ target : None = None ,
4534
+ inplace : bool = False ,
4535
+ ) -> DataFrame | None :
4492
4536
"""
4493
4537
Query the columns of a DataFrame with a boolean expression.
4494
4538
@@ -4624,10 +4668,17 @@ def query(self, expr: str, *, inplace: bool = False, **kwargs) -> DataFrame | No
4624
4668
if not isinstance (expr , str ):
4625
4669
msg = f"expr must be a string to be evaluated, { type (expr )} given"
4626
4670
raise ValueError (msg )
4627
- kwargs ["level" ] = kwargs .pop ("level" , 0 ) + 1
4628
- kwargs ["target" ] = None
4629
4671
4630
- res = self .eval (expr , ** kwargs )
4672
+ res = self .eval (
4673
+ expr ,
4674
+ parser ,
4675
+ engine ,
4676
+ local_dict ,
4677
+ global_dict ,
4678
+ resolvers ,
4679
+ level + 1 ,
4680
+ target ,
4681
+ )
4631
4682
4632
4683
try :
4633
4684
result = self .loc [res ]
0 commit comments