-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Augmented arithmetic assignments will modify original series starting version 1.1.4 #38519
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
Comments
Thanks @nikita-ivanov for the report.
This was changed in [d8c8cbb] REGR: inplace Series op not actually operating inplace (#37508) to fix a regression for DataFrame behaviour. It looks like is also corrected a long standing bug/inconsistency with the series behaviour. |
@simonjayhawkins thanks for the update. Do I see it correctly that the future behavior would the same as it is now for s = pd.Series([1, 2, 3])
s1 = s.iloc[1:]
s1 -= 4
s
# output
# 0 1
# 1 -2
# 2 -1
# dtype: int64
s = pd.Series([1, 2, 3])
s1 = s.iloc[1:]
s1 = s1 - 4
s
# output
# 0 1
# 1 -2
# 2 -1
# dtype: int64 |
for the
in Python, the Under the hood, Python calls 'special methods' for the various syntactical constructs. in this case if the object, in this case In general, for mutable sequences, it is common for A pandas Series is a mutable sequence that implements |
@simonjayhawkins thanks for clarifications. My concern is that prior to |
@nikita-ivanov I agree that a long standing behaviour has been changed without adequate notice. We will await comment from @jbrockmendel for the way forward here. I am reluctant to add a regression tag here as I think the new behaviour is more correct and we are not currently planning any more releases in the 1.1.x series. |
Agreed. |
So, should the release notes be clarified, or can this be closed? @jbrockmendel |
If someone wants to flesh out a release note i wont object |
I'd like to take it and clarify on the release note. I'd like to let you know that this is my first time contributing. |
Sure, go ahead - here's the contributing guide https://pandas.pydata.org/docs/dev/development/contributing_docstring.html , please do ask (here or on Slack) if anything's not clear |
@MarcoGorelli, Thank you. I'm reading the contributing guide. |
Hey - for Slack: https://pandas.pydata.org/docs/dev/development/community.html?highlight=slack#community-slack I'd suggest just rewording pandas/doc/source/whatsnew/v1.1.4.rst Line 34 in ac648ee
, e.g. to
|
@MarcoGorelli, thank you for directing me to join Slack. And thank you for your suggestion. I'm not able to open
to reword it. How can I access the docstring? Do I need to do it through my GitHut account? Thank you. |
Yeah you'll need to fork the repo, clone it, checkout a new branch, stage, commit, push, open a pull request - if you read through https://pandas.pydata.org/docs/dev/development/contributing.html it should all be explained, else we're available on Slack to help out |
take |
@SophiaTangHart Hi there, do you mind if I take the issue since it seems to be inactive for some time? |
Sure. Sorry for taking a while. I've unassigned myself. Thanks. |
take |
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.
Code Sample, a copy-pastable example
Problem description
Starting with version
1.1.4
when applying either of+=
,-=
,*=
or/=
operators on a seriess1
that was sliced from original seriess
, the change propagates to original seriess
. When using normal assignment operatorss1 = s1 - 4
the problem is not present, which leads to inconsistent behavior.Output of
pd.show_versions()
INSTALLED VERSIONS
commit : 67a3d42
python : 3.7.9.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.18362
machine : AMD64
processor : Intel64 Family 6 Model 158 Stepping 13, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : None.None
pandas : 1.1.4
numpy : 1.17.2
pytz : 2020.4
dateutil : 2.8.0
pip : 20.3.3
setuptools : 51.0.0.post20201207
Cython : 0.28.5
pytest : 3.8.1
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.19.0
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : 3.3.3
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pyxlsb : None
s3fs : None
scipy : 1.5.4
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None
The text was updated successfully, but these errors were encountered: