-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: DataFrame.at must fail when adding more than one value #48362
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: DataFrame.at must fail when adding more than one value #48362
Conversation
73123f9
to
e8b61fc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm in general. Could you check if this impacts #48323?
On a second thought, I was just checking if this was also working in the past, and it seems the test example here has "correctly" worked basically forever (I tested down to 0.18). So we should maybe consider deprecating this first? |
The problem occurred because when adding a new column to a DataFrame using DataFrame.at, DataFrame._set_value falls back to DataFrame.loc before the InvalidIndexError is raised. The proposed solution makes sure that both, the column index and the row index are determined so that both have a chance to raise.
e8b61fc
to
f7dad6d
Compare
Since 0.23 there is the sentence Use at if you only need to get or set a single value in a DataFrame or Series. in the docs. So we could consider it deprecated since then. But I wouldn't mind deprecating "officially". |
I would disallow immediately. Using the same indexer again raises, so we would fix an inconsistency on top of that. |
If we really decide that If we decide to merge this, I would suggest also fixing the docstring of So decision needed. |
@johannes-mueller In |
I am working on a PR that will do this exact thing, including modifying the user guide and documentation. I'll link it here once I'm done with it so we can decide what to do to fix this bug. |
I've finally submitted my PR. You can find it at #48542. |
Superseded by #48542 |
Greetings from EuroScipy 2022 and thanks to @jorisvandenbossche for support.
The problem occurred because when adding a new column to a DataFrame using
DataFrame.at, DataFrame._set_value falls back to DataFrame.loc before the
InvalidIndexError is raised.
The proposed solution makes sure that both, the column index and the row index
are determined so that both have a chance to raise.
doc/source/whatsnew/v1.6.0.rst
file if fixing a bug or adding a new feature.