Skip to content

Conversation

Talyahav17
Copy link
Contributor

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

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

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

@mroeschke mroeschke added the Docs label Sep 15, 2025
@Talyahav17
Copy link
Contributor Author

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

@jbrockmendel
Copy link
Member

can you get the CI passing

@mroeschke mroeschke added this to the 3.0 milestone Oct 5, 2025
@mroeschke mroeschke merged commit 1627e2b into pandas-dev:main Oct 5, 2025
42 checks passed
@mroeschke
Copy link
Member

Thanks @Talyahav17

jzwick pushed a commit to jzwick/pandas that referenced this pull request Oct 8, 2025
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.

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

3 participants