Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

DOC: clarify Series.map behavior for categorical dtype #62338

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

Open
Talyahav17 wants to merge 7 commits into pandas-dev:main
base: main
Choose a base branch
Loading
from Talyahav17:doc/clarify-categorical-map

Conversation

Copy link

@Talyahav17 Talyahav17 commented Sep 14, 2025

Comment on lines 1554 to 1558
Notes
-----
The mapping function is applied to the categories, not to
each element of the array.
Copy link
Member

@mroeschke mroeschke Sep 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you show this in the Examples section instead?

Comment on lines 4392 to 4397
When the Series has ``⁠dtype="category"⁠``, the function is applied
to the categories and not to each individual value. This means
that if the same category appears multiple times, the function is
only called once for that category, and the result is reused for
all occurrences. Missing values (NaN) are not passed to the function.
Copy link
Member

@mroeschke mroeschke Sep 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is sufficiently shown in the example below

Copy link
Author

moved categorical note into Categorical.map Examples and removed redundant paragraph from Series.map Note

Copy link
Member

can you get the CI passing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@mroeschke mroeschke mroeschke left review comments

Assignees
No one assigned
Labels
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Series.map on a Categorical with a function only processes each unique value once

AltStyle によって変換されたページ (->オリジナル) /