Skip to content

REGR: inplace arithmetic operation on Series no longer updating parent DataFrame #36373

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

Closed
3 tasks done
hjweide opened this issue Sep 15, 2020 · 6 comments · Fixed by #37508
Closed
3 tasks done

REGR: inplace arithmetic operation on Series no longer updating parent DataFrame #36373

hjweide opened this issue Sep 15, 2020 · 6 comments · Fixed by #37508
Labels
Copy / view semantics Regression Functionality that used to work in a prior pandas version
Milestone

Comments

@hjweide
Copy link

hjweide commented Sep 15, 2020

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • (optional) I have confirmed this bug exists on the master branch of pandas.


Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.

Code Sample, a copy-pastable example

import pandas as pd

df = pd.DataFrame({"A": [1, 2, 3]})

a = df["A"]
a += 999

print(df)
print(df["A"])

assert a is df["A"]

Problem description

I expect print(df) and print(df["A"]) to show identical values for column A. This is not the case. The output of the code above:

   A
0  1
1  2
2  3
0    1000
1    1001
2    1002
Name: A, dtype: int64

Expected Output

   A
0  1000
1  1001
2  1002
0    1000
1    1001
2    1002
Name: A, dtype: int64

Output of pd.show_versions()

INSTALLED VERSIONS

commit : fd20f7d
python : 3.8.2.final.0
python-bits : 64
OS : Linux
OS-release : 5.4.0-47-generic
Version : #51-Ubuntu SMP Fri Sep 4 19:50:52 UTC 2020
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 1.2.0.dev0+379.gfd20f7d34
numpy : 1.19.2
pytz : 2020.1
dateutil : 2.8.1
pip : 20.0.2
setuptools : 44.0.0
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None
None

Possibly related to #36051?

@hjweide hjweide added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Sep 15, 2020
@dsaxton dsaxton added Copy / view semantics Regression Functionality that used to work in a prior pandas version and removed Bug Needs Triage Issue that has not been reviewed by a pandas team member Copy / view semantics labels Sep 15, 2020
@dsaxton
Copy link
Member

dsaxton commented Sep 15, 2020

This is a regression from 1.0.5 and seems this line is the cause:

self._reset_cacher()


a3097b5 is the first bad commit
commit a3097b5
Author: rjfs rafajfsantos@gmail.com
Date: Thu Mar 26 13:53:13 2020 +0100

BUG: Fixed strange behaviour of pd.DataFrame.drop() with inplace argu… (#30501)

doc/source/whatsnew/v1.1.0.rst | 1 +
pandas/core/ops/methods.py | 3 ++-
pandas/tests/frame/test_axis_select_reindex.py | 21 +++++++++++++++++++++
3 files changed, 24 insertions(+), 1 deletion(-)

@jorisvandenbossche jorisvandenbossche added this to the 1.1.3 milestone Sep 15, 2020
@jorisvandenbossche jorisvandenbossche changed the title BUG: inplace operation on pd.Series is not reflected when printing parent pd.DataFrame REGR: inplace arithmetic operation on Series no longer updating parent DataFrame Sep 15, 2020
@simonjayhawkins
Copy link
Member

This is a regression from 1.0.5 and seems this line is the cause:

@dsaxton I think helps to add the PR number so that github creates a link (I have found duplicate issues in the past by doing this)

#30501

@simonjayhawkins
Copy link
Member

moved off 1.1.3 milestone, see #36498 (comment)

@simonjayhawkins
Copy link
Member

moved off 1.1.4 milestone (scheduled for release tomorrow)

@jorisvandenbossche
Copy link
Member

Since the consensus on the PR seems to be to revert the original patch, let me quickly do that.

@jorisvandenbossche jorisvandenbossche modified the milestones: 1.1.5, 1.1.4 Oct 29, 2020
@simonjayhawkins
Copy link
Member

Since the consensus on the PR seems to be to revert the original patch, let me quickly do that.

if you need to feel free to put a note in other, i'll update #37496 if necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment