-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
Fixed regression for SettingWithCopyWarning showing incorrect stacklevel #42633
Conversation
df = DataFrame(np.arange(25).reshape(5, 5)) | ||
chained = df.loc[:3] | ||
with option_context("chained_assignment", "warn"): | ||
with tm.assert_produces_warning(com.SettingWithCopyWarning) as t: |
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 think check_stacklevel
is supposed to do this?
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.
Yeah thought so too, but test was passing with stacklevel 4 and 5
@@ -3745,7 +3745,7 @@ def _set_item_mgr(self, key, value: ArrayLike) -> None: | |||
# try to set first as we want an invalid | |||
# value exception to occur first | |||
if len(self): | |||
self._check_setitem_copy() | |||
self._check_setitem_copy(stacklevel=5) |
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.
you can use the find_stack_level
function i think its called
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.
yah at first i was trying to use find_stack_level sparingly, but might as well go for it
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.
Will do that as a follow up, since this would change the function signature I don't think we should backport this?
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.
sure that's fine
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
merging |
…ning showing incorrect stacklevel
…ng incorrect stacklevel (#42678) Co-authored-by: Patrick Hoefler <[email protected]>
…vel (pandas-dev#42633) Co-authored-by: Jeff Reback <[email protected]>
…vel (pandas-dev#42633) Co-authored-by: Jeff Reback <[email protected]>
SettingWithCopyWarning
on new pandas version #42570Is there a better way to check the stacklevel here?