Skip to content

DOC: add docstring with examples to NDFrame.__invert__ (~ operator)#65291

Open
RudrenduPaul wants to merge 1 commit intopandas-dev:mainfrom
RudrenduPaul:DOC-add-invert-docstring
Open

DOC: add docstring with examples to NDFrame.__invert__ (~ operator)#65291
RudrenduPaul wants to merge 1 commit intopandas-dev:mainfrom
RudrenduPaul:DOC-add-invert-docstring

Conversation

@RudrenduPaul
Copy link
Copy Markdown

Problem description

The __invert__ dunder method (the ~ tilde operator) has no docstring in NDFrame, so Series.__invert__ and DataFrame.__invert__ show only the signature in the generated API docs with no explanation or examples.

Issue: #62516

A maintainer confirmed in that issue that documenting dunder methods broadly is a positive direction.

Changes

  • Added a numpydoc-style docstring to NDFrame.__invert__ in pandas/core/generic.py with:
    • A description of the behavior for boolean (logical NOT) and integer (bitwise NOT) data
    • Returns, See Also, and Examples sections
    • Three working doctests covering boolean Series, integer Series, and boolean DataFrame
  • Registered Series.__invert__ in doc/source/reference/series.rst under Binary operator functions

Checklist

  • Tests added and passed
  • Whatsnew entry not needed (documentation-only addition)

The __invert__ dunder method (the ~ operator) had no docstring,
making it invisible in the API docs and undiscoverable for users
who don't know to search for the tilde operator by name.

Adds a numpydoc-style docstring to NDFrame.__invert__ in generic.py
covering boolean and integer Series, plus a DataFrame example, and
registers Series.__invert__ in the Series API reference RST.

Closes pandas-dev#62516

Built by Rudrendu Paul, developed with Claude Code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant