Skip to content

API: Rename arg to func in Series.map #61264

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

Merged
merged 11 commits into from
Apr 14, 2025

Conversation

datapythonista
Copy link
Member

CC: @rhshadrach

@datapythonista datapythonista added Apply Apply, Aggregate, Transform, Map API - Consistency Internal Consistency of API/Behavior labels Apr 10, 2025
@@ -372,6 +372,7 @@ Other API changes
- Index set operations (like union or intersection) will now ignore the dtype of
an empty ``RangeIndex`` or empty ``Index`` with object dtype when determining
the dtype of the resulting Index (:issue:`60797`)
- Renamed the ``arg`` parameter of ``Series.map`` to ``func``. (:issue:`61260`)
Copy link
Member

Choose a reason for hiding this comment

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

This should be in deprecations?

Copy link
Member Author

Choose a reason for hiding this comment

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

I moved it there. Since it's renaming a parameter both deprecations and API changed made sense, but I have no preference.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks - the way I read API changes is "things I need to change to not have my code break when upgrading". As this is a deprecation, users don't need to do that just yet.

Comment on lines +4410 to +4411
if func is None:
if "arg" in kwargs:
Copy link
Member

Choose a reason for hiding this comment

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

Noting this won't be backwards compatible with the use Series.map(arg=foo, func=myfunc) where myfunc is an argument of foo. This seems unlikely enough that I am okay here.

Copy link
Member Author

Choose a reason for hiding this comment

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

You are totally right. In my first implementation I was raising an exception, and then thought it would be better to allow using arg as an argument name of the udf. If we want to be very conservative we could raise now, and stop raising when we remove the deprecation and arg is no longer accepted as the argument name of the function.

But as you, I think is better to just let that unlikely case break compatibility.

Copy link
Member

@rhshadrach rhshadrach left a comment

Choose a reason for hiding this comment

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

lgtm - just need to fix order of the items in the whatsnew due to my suggested change.

@rhshadrach rhshadrach added this to the 3.0 milestone Apr 14, 2025
@rhshadrach rhshadrach merged commit 07c627c into pandas-dev:main Apr 14, 2025
42 checks passed
@rhshadrach
Copy link
Member

Thanks @datapythonista

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API: Rename arg to func in Series.map for consistency
2 participants