-
- Notifications
You must be signed in to change notification settings - Fork 19.4k
Description
Pandas version checks
-
I have checked that this issue has not already been reported.
-
I have confirmed this bug exists on the latest version of pandas.
-
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
import pandas as pd with pd.option_context("mode.copy_on_write", False): df = pd.DataFrame({"a": [1,2,3], "b": [2,4,6]}) df2 = df.loc[0:1,:] df2.iloc[0,0] = 9999Issue Description
Under both Python 3.12 and 3.14, with the main branch of Pandas (see details below), the reproducible example does not show the SettingWithCopyWarning.
Possibly related to #61368 (closed), since it probably also has to do with refcounts. This bug happens on multiple versions of Python, though, instead of only with Python 3.14.
Expected Behavior
To show the SettingWithCopyWarning. Under Pandas 2.3.3 it works fine and does show the warning:
SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy df2.iloc[0,0] = 9999 As in the example, users may choose to disable copy-on-write (pd.options.mode.copy_on_write = False) in order to use the view of a data frame with working assignment on the original data frame, as is the default in Pandas < 3.0. However, if they choose to disable copy-on-write, they still should be warned that they are modifying the original data frame, just like in Pandas < 3.0.
Installed Versions
INSTALLED VERSIONS
commit : 809d9b7
python : 3.12.12
python-bits : 64
OS : Windows
OS-release : 11
Version : 10.0.26200
machine : AMD64
processor : Intel64 Family 6 Model 170 Stepping 4, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : English_United Kingdom.1252
pandas : 3.0.0.dev0+2755.g809d9b72a0
numpy : 2.3.5
dateutil : 2.9.0.post0
pip : None
Cython : None
sphinx : None
IPython : 9.7.0
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : None
bottleneck : None
fastparquet : None
fsspec : None
html5lib : None
hypothesis : None
gcsfs : None
jinja2 : 3.1.6
lxml.etree : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
psycopg2 : None
pymysql : None
pyarrow : None
pyiceberg : None
pyreadstat : None
pytest : None
python-calamine : None
pytz : 2025.2
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlsxwriter : None
zstandard : None
qtpy : None
pyqt5 : None