Skip to content

DOC: clarify pandas.unique return type#65638

Merged
mroeschke merged 1 commit into
pandas-dev:mainfrom
jbrockmendel:bug-47426
May 16, 2026
Merged

DOC: clarify pandas.unique return type#65638
mroeschke merged 1 commit into
pandas-dev:mainfrom
jbrockmendel:bug-47426

Conversation

@jbrockmendel
Copy link
Copy Markdown
Member

closes #47426

Summary

  • Rewrite the Returns section of pandas.unique to spell out the three actual dispatch paths in unique_with_mask: Index input → Index, ExtensionDtype input → ExtensionArray of same dtype, everything else → numpy.ndarray.
  • The old text listed only Categorical for the EA case, claimed Series/ndarray always returns ndarray (misleading for EA-backed Series), and ended with a redundant trailing line.

Test plan

  • All 12 existing pd.unique doctests still pass
  • Pre-commit hooks pass

Spell out the three return-type cases by dispatch path: Index input
returns an Index, ExtensionDtype input returns an ExtensionArray of
the same dtype, and any other input returns numpy.ndarray.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@mroeschke mroeschke added the Docs label May 16, 2026
@mroeschke mroeschke added this to the 3.1 milestone May 16, 2026
@mroeschke mroeschke merged commit a3cb75f into pandas-dev:main May 16, 2026
51 checks passed
@mroeschke
Copy link
Copy Markdown
Member

Thanks @jbrockmendel

@jbrockmendel jbrockmendel deleted the bug-47426 branch May 17, 2026 02:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Documentation improvement regarding returned datatype of pandas.unique

2 participants