Skip to content

ENH: Add notin method to base classes #43959

@ShivnarenSrinivasan

Description

@ShivnarenSrinivasan

Add notin convenience method to DataFrame/Series classes

This may already have been discussed, but I couldn't find any existing issue/enhancement with this title.
It's trivial to implement, but I think it might be syntactically helpful to write

df.notin(df1)

instead of

~df.isin(df1)

especially in longer expressions where the boolean array is being used to slice a dataframe.

Describe the solution you'd like

Add a convenience function which returns the not value of df.isin

API breaking implications

No impact on API.

Additional context

This has already been done for isna/notna, and I find it very helpful—just borrowing the same idea.

Copied from frame.py:

   @doc(NDFrame.isna, klass=_shared_doc_kwargs["klass"])
    def isna(self) -> DataFrame:
        result = self._constructor(self._mgr.isna(func=isna))
            return result.__finalize__(self, method="isna")

    @doc(NDFrame.notna, klass=_shared_doc_kwargs["klass"])
    def notna(self) -> DataFrame:
        return ~self.isna()

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocsIndexingRelated to indexing on series/frames, not to indexes themselvesNeeds TriageIssue that has not been reviewed by a pandas team member

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions