-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Changed .at to not set values that do not exist yet in a DataFrame #48323 #48542
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
Conversation
Does this overlap with #48362? If so I would recommend allowing @johannes-mueller to continue with that PR first |
In that PR, @johannes-mueller stated that if the behavior was made so that |
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.
I like this one. It can supersede #48362.
@@ -234,3 +237,9 @@ def test_at_categorical_integers(self): | |||
for key in [0, 1]: | |||
with pytest.raises(KeyError, match=str(key)): | |||
df.at[key, key] | |||
|
|||
def test_at_does_not_expand(self): |
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.
Maybe we should have two tests here, one for expansion in column axis and another one for expansion in index axis.
expected = DataFrame( | ||
[[10, 10], [0, 0], [0, 0]], | ||
columns=MultiIndex.from_tuples([("a", 0), ("a", 1)]), | ||
) | ||
tm.assert_frame_equal(df, expected) | ||
with pytest.raises(TypeError, match=""): |
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.
Personally, I would put this into a separate test. One test for the happy path and one for the failing path. YMMV
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.
I don't want to split this because this isn't actually a test I created, but one I had to modify based on the code change, so I'd like to keep the change as small as I reasonably can.
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.
Well, fair enough.
Personally I am really reluctant to modify existing tests. So I would rather add a new one. YMMV
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.
From #48542, I think this needs deprecating. It is documented in the User Guide, so it would be a breaking change.
@rhshadrach How does the deprecation process work in Pandas? Is there something I should do, or does it just mean that someone else needs to announce the change before accepting my PR? (Note that my PR does include a change to the user guide to make it more accurate.) |
The behavior that is to be deprecated needs to raise a |
This pull request is stale because it has been open for thirty days with no activity. Please update and respond to this comment if you're still interested in working on this. |
Closing as stale. @srotondo - if you'd like to pick this back up and deprecate the behavior, we can reopen. |
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.