From 3dd142b6d399e2cd1edd7fd5ccf3a6a9464887d4 Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Fri, 5 Dec 2025 15:41:21 +0100 Subject: [PATCH] DOC: update copy keyword explanation in astype docstring --- pandas/core/generic.py | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index ea133e9a83adb..869a8163694d5 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -6354,23 +6354,15 @@ def astype( a numpy.dtype or Python type to cast one or more of the DataFrame's columns to column-specific types. copy : bool, default False - Return a copy when ``copy=True`` (be very careful setting - ``copy=False`` as changes to values then may propagate to other - pandas objects). + .. deprecated:: 3.0.0 - .. note:: - The `copy` keyword will change behavior in pandas 3.0. - `Copy-on-Write + This keyword is ignored and will be removed in pandas 4.0. Since + pandas 3.0, this method always returns a new object using a lazy + copy mechanism that defers copies until necessary + (Copy-on-Write). See the `user guide on Copy-on-Write `__ - will be enabled by default, which means that all methods with a - `copy` keyword will use a lazy copy mechanism to defer the copy and - ignore the `copy` keyword. The `copy` keyword will be removed in a - future version of pandas. - - You can already get the future behavior and improvements through - enabling copy on write ``pd.options.mode.copy_on_write = True`` + for more details. - .. deprecated:: 3.0.0 errors : {'raise', 'ignore'}, default 'raise' Control raising of exceptions on invalid data for provided dtype.