Skip to content
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: ChainedAssignmentError link to documentation will break? #58716

Closed
2 of 3 tasks
simonjayhawkins opened this issue May 14, 2024 · 2 comments · Fixed by #58726
Closed
2 of 3 tasks

BUG: ChainedAssignmentError link to documentation will break? #58716

simonjayhawkins opened this issue May 14, 2024 · 2 comments · Fixed by #58726
Labels
Bug Copy / view semantics Docs Needs Triage Issue that has not been reviewed by a pandas team member

Comments

@simonjayhawkins
Copy link
Member

simonjayhawkins commented May 14, 2024

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

df = pd.DataFrame({"foo": [1, 2, 3], "bar": [4, 5, 6]})
df["foo"].iloc[0] = 100

Issue Description

on main this gives

/tmp/ipykernel_19965/196554192.py:2: ChainedAssignmentError: A value is trying to be set on a copy of a DataFrame or Series through chained assignment.
When using the Copy-on-Write mode, such chained assignment never works to update the original DataFrame or Series, because the intermediate object on which we are setting values always behaves as a copy.

Try using '.loc[row_indexer, col_indexer] = value' instead, to perform the assignment in a single step.

See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
  df["foo"].iloc[0] = 100

however https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy does not exist in the dev docs. (removed in #56614)

(also should the link in doc/source/whatsnew/v2.2.0.rst not fail the doc build?)

cc @phofl

Expected Behavior

probably should link to Why does assignment fail when using chained indexing? or maybe directly to https://pandas.pydata.org/docs/.../user_guide/copy_on_write.html

Installed Versions

INSTALLED VERSIONS

commit : 67055d5
python : 3.10.14.final.0
python-bits : 64
OS : Linux
OS-release : 5.4.72-microsoft-standard-WSL2
Version : #1 SMP Wed Oct 28 23:40:43 UTC 2020
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 3.0.0.dev0+272.g67055d5944
numpy : 1.26.4
pytz : 2024.1
dateutil : 2.9.0
setuptools : 69.5.1
pip : 24.0
Cython : 3.0.10
pytest : 8.2.0
hypothesis : 6.101.0
sphinx : 7.3.7
blosc : None
feather : None
xlsxwriter : 3.1.9
lxml.etree : 5.2.2
html5lib : 1.1
pymysql : 1.4.6
psycopg2 : 2.9.9
jinja2 : 3.1.4
IPython : 8.24.0
pandas_datareader : None
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.12.3
bottleneck : 1.3.8
fastparquet : 2024.2.0
fsspec : 2024.3.1
gcsfs : 2024.3.1
matplotlib : 3.8.4
numba : 0.59.1
numexpr : 2.9.0
odfpy : None
openpyxl : 3.1.2
pyarrow : 15.0.2
pyreadstat : 1.2.7
python-calamine : None
pyxlsb : 1.0.10
s3fs : 2024.3.1
scipy : 1.13.0
sqlalchemy : 2.0.30
tables : 3.9.2
tabulate : 0.9.0
xarray : 2024.3.0
xlrd : 2.0.1
zstandard : 0.22.0
tzdata : 2024.1
qtpy : None
pyqt5 : None

@simonjayhawkins simonjayhawkins added Bug Docs Needs Triage Issue that has not been reviewed by a pandas team member Copy / view semantics labels May 14, 2024
@SiddheshBangar
Copy link
Contributor

Hey @simonjayhawkins, I was just checking your issue as I am new into open source so I was just looking into how I can contribute to it.

As per my understanding your issue is, that the link mentioned in the error is just not relevant and has been removed due to one of the previous PRs and doc updates.

So the link should be replaced with your mentioned link https://pandas.pydata.org/pandas-docs/stable/user_guide/copy_on_write.html that can help in solve this problem, right?

@simonjayhawkins
Copy link
Member Author

So the link should be replaced with your mentioned link https://pandas.pydata.org/pandas-docs/stable/user_guide/copy_on_write.html that can help in solve this problem, right?

yes, I think so. but I left the triage label on so that another set of eyes could confirm what the best solution would be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Copy / view semantics Docs Needs Triage Issue that has not been reviewed by a pandas team member
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants