-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Better flexibility of pandas warnings #2842
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
I'm curious about the internationalization issue you mention, not sure |
Some warnings and errors are only relevant for the programmer, but sometimes the warnings/errors will be shown to the end user. So if your software is used by people with different languages (like french and spanish), it's common to have the code throw "this is an error" for english users, but spanish users would see "esto es un error" instead, and french users would see it translated into french, etc. Obviously, you can't have a reg ex expression match all the different languages; so you need a system where each error/warning has a unique name/id. Granted, most python programmers would never bother to handle multiple languages in their strings -- that's more common in "big, professional" software written in C++/Java/C#. So I'm not saying internationalization is the major reason we should implement my proposal above. Getting internationalization is just a bonus. The real reason we need this feature isn't for internationalization; it's for the issue described on #1893 (way at the bottom of the thread) |
ok then. since pandas is not internationalized, that's not an issue. Note that what you're asking can be made without new code, just by prefixing each warning that scheme would work for i18n as well, if it was implemented. As mentioned in #1893, that specific warning will go away permanently in the upcoming 0.11.0, |
Yes, prefixing each warning with a unique number would be sufficient (as long as the different warnings that are really the same warning have the same number -- for instance, on #1893, the set_index warning on line 2762 should have the same number as the sort warning on 3192 and the fillna error on line 2479, since they're really the exact same warning just appearing in different places). I'd be OK with that solution as long as its followed consistently. I understand you that the specific warnings I cite will be going away in the next release. I just want to find a way to handle warnings better for the next time. |
Closing as a won't fix for now given the low activity. If people are interested to actually discuss this / work on this, we can certainly re-open the issue. |
From #1893 (scroll down a long way to the bottom) -- pandas is throwing a warning that we want to disable; but the same conceptual warning is being thrown from many different lines of code, with slightly different messages each time, so there's no way to filter them all out at once.
The python standard warning.filterwarning() method is fragile, cause you have to either
So why not give pandas a more robust way of disabling warnings, maybe something like the C++ #pragma warning macro ( http://msdn.microsoft.com/en-us/library/2c8f766e%28v=vs.80%29.aspx ) Something like:
pandas.warnings.disable("InPlaceReturnsObjectIsBeingDeprecated")
pandas.warnings.disable("SomeOtherSpecificWarning")
Or alternatively, instead of a name, maybe that takes a number specifying the warning. Gives maximum flexibility, robustness, and safety when upgrading to the next version.
The text was updated successfully, but these errors were encountered: