diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 051ebfff47f83..ae5d6b3c17423 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -4596,7 +4596,15 @@ def eval(self, expr: str, *, inplace: bool = False, **kwargs) -> Any | None: kwargs["target"] = self kwargs["resolvers"] = tuple(kwargs.get("resolvers", ())) + resolvers - return _eval(expr, inplace=inplace, **kwargs) + result = _eval(expr, inplace=inplace, **kwargs) + + # Extract the engine from kwargs or use the default value "numexpr" + engine = kwargs.get("engine") + + if engine == "numexpr" and inplace is False: + return result.__finalize__(self, method="eval") + else: + return result def select_dtypes(self, include=None, exclude=None) -> Self: """ diff --git a/pandas/tests/generic/test_finalize.py b/pandas/tests/generic/test_finalize.py index 3c4ea5bd1fb2c..9703d2ced15f3 100644 --- a/pandas/tests/generic/test_finalize.py +++ b/pandas/tests/generic/test_finalize.py @@ -460,7 +460,6 @@ def test_finalize_called(ndframe_method): assert result.attrs == {"a": 1} -@not_implemented_mark def test_finalize_called_eval_numexpr(): pytest.importorskip("numexpr") df = pd.DataFrame({"A": [1, 2]})