-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BUG: pandas-1.4.0 .loc "shallow" copies do not update #45743
Comments
The .loc views are behaving correctly. The change is that df["a"] = df["a"] * 2 is now creating a new array instead of writing into the existing array. See https://pandas.pydata.org/pandas-docs/stable/whatsnew/v1.4.0.html#bug-fixes Setting with |
Cool, thanks for the quick response and my apologies for not linking it to #43406 and other associated issues. I did search through the bug-fixes of 1.4.0 and issues but was looking for mention of Glad to see everything is in hand, thanks. |
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
Issue Description
When taking a "shallow" slice of a dataframe with
.loc
subsequent updates should be reflected in the original and vice-versa, this is no longer the case under Pandas 1.4.0 as demonstrated running the reproducible example...After
original["a"] = original["a"]**2 the values at
.loc[1:2,"a"]are
2.340512and
0.107903and should be the same under a "
Plain" copy and "
Shallow`" copy as the documentation states only a "deep" copy should take a snapshot of the original and shallow copies share data and index with original..Expected Behavior
The behaviour under 1.3.5 is as described in the manual, after modifying the original a "plain" and "shallow" copy reflect the modifications...
Installed Versions
INSTALLED VERSIONS
commit : bb1f651
python : 3.8.12.final.0
python-bits : 64
OS : Linux
OS-release : 4.15.0-123-generic
Version : #126-Ubuntu SMP Wed Oct 21 09:40:11 UTC 2020
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_GB.UTF-8
LOCALE : en_GB.UTF-8
pandas : 1.4.0
numpy : 1.22.1
pytz : 2021.3
dateutil : 2.8.2
pip : 21.3.1
setuptools : 60.5.0
Cython : 0.29.26
pytest : 6.2.5
hypothesis : None
sphinx : 4.4.0
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.7.1
html5lib : None
pymysql : None
psycopg2 : 2.9.3
jinja2 : 3.0.3
IPython : 8.0.1
pandas_datareader: None
bs4 : 4.10.0
bottleneck : None
fastparquet : None
fsspec : 2022.01.0
gcsfs : None
matplotlib : 3.5.1
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.7.3
sqlalchemy : 1.4.31
tables : None
tabulate : 0.8.9
xarray : 0.20.2
xlrd : 2.0.1
xlwt : None
zstandard : None
The text was updated successfully, but these errors were encountered: