-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
WARN should SettingWithCopyWarning be shown multiple times in a Python REPL? #50209
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
To get this to work for something like warnings.simplefilter("always", SettingWithCopyWarning) Users can turn off the warnings by placing warnings.simplefilter("ignore", SettingWithCopyWarning) in their code. |
If we desire to always state a warning by default, we should evaluate it for any of the specialized pandas warnings: AccessorRegistrationWarning
AttributeConflictWarning
CategoricalConversionWarning
CSSWarning
DtypeWarning
IncompatibilityWarning
ParserWarning
PerformanceWarning
SettingWithCopyWarning And from #49024 use the correct warning there |
I'm generally positive, but I think we need to be careful with warnings that have been added with the expectation that they would only be seen once. E.g. it can happen that when looping over the columns of a DataFrame a warning gets emitted for each column. This type of behavior is what lead to the reverts of using |
That's why I suggested we look at each warning and decide whether we warn "always" or "once". For the one in #49024, the warning gets emitted each time you call |
This came out of a discussion here: #49024 (comment)
When running pandas in a Python REPL, this warning is only shown once per session.
So, if it was raised from two different objects, a user could miss it in the second one:
Should it be shown multiple times?
There's a suggestion for how to do this here:
I've opened this issue to split out the conversation, as it's not specific to #49024
The text was updated successfully, but these errors were encountered: