diff --git a/python/pyspark/pandas/frame.py b/python/pyspark/pandas/frame.py index 1e5ebb46dfe8..caa6251c1219 100644 --- a/python/pyspark/pandas/frame.py +++ b/python/pyspark/pandas/frame.py @@ -13312,6 +13312,10 @@ def eval_func(pdf): # type: ignore[no-untyped-def] nonlocal should_return_series nonlocal series_name nonlocal should_return_scalar + if inplace and LooseVersion(pd.__version__) >= "3.0.0": + # pandas 3 can reject inplace eval on a read-only batch frame, + # so evaluate against a writable copy. + pdf = pdf.copy() result_inner = pdf.eval(expr, inplace=inplace) if inplace: result_inner = pdf