Skip to content

Better flexibility of pandas warnings #2842

@darindillon

Description

@darindillon

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

  1. specify line number (which will break in the next release when line numbers change)
  2. specify regex for the error message (which will break when the error message text changes, plus it's not safe for internationalization)
  3. specify the module (which will filter out the warning you want to disable, but also filters out all the OTHER warnings which you want to keep).

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions