-
-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
ENH: Add kwargs to Series.map
#59814
Labels
API - Consistency
Internal Consistency of API/Behavior
Apply
Apply, Aggregate, Transform, Map
Enhancement
Comments
RomeshA
added
Enhancement
Needs Triage
Issue that has not been reviewed by a pandas team member
labels
Sep 16, 2024
Thanks for the request. Agreed we should be consistent here by adding |
rhshadrach
added
Apply
Apply, Aggregate, Transform, Map
API - Consistency
Internal Consistency of API/Behavior
and removed
Needs Triage
Issue that has not been reviewed by a pandas team member
labels
Sep 18, 2024
take |
5 tasks
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
API - Consistency
Internal Consistency of API/Behavior
Apply
Apply, Aggregate, Transform, Map
Enhancement
Feature Type
Adding new functionality to pandas
Changing existing functionality in pandas
Removing existing functionality in pandas
Problem Description
In version 2.2,
pandas.DataFrame.map
supports passing additional arguments to functions used when mapping values. However, this functionality is not provided bypandas.Series.map
. It would be more consistent and useful if bothmap
functions had the same signatureFeature Description
The signature of
Series.map
would be 'Series.map(func, na_action=None, **kwargs)' rather thanSeries.map(arg, na_action=None)
with the additionalkwargs
provided to thefunc
at the point when mapping is performedAlternative Solutions
Users can replace their function
func
withfunctools.partial(func, **kwargs)
to achieve the same functionality - this is whatDataFrame.map
seems to use internally.Additional Context
Presumably the difference is because
Series.map()
supports functions, dicts, or Series instances, whereasDataFrame.map()
only supports functions? Since their use cases are so similar and they even share a name, it would probably be easiest for both users if bothmap
functions had the same feature set, one way or anotherThe text was updated successfully, but these errors were encountered: