-
-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Open
Labels
API DesignApplyApply, Aggregate, Transform, MapApply, Aggregate, Transform, MapNeeds DiscussionRequires discussion from core team before further actionRequires discussion from core team before further action
Description
The signature of Series.apply
(and DataFrame.apply
) seems inconsistent and cumbersome (see args
and **kwargs
:
Series.apply(func, convert_dtype=True, args=(), **kwargs)
I'd expect to have args
and kwargs
, or *args
and **kwargs
, not a mix of both. I assume this was implemented to allow convert_dtype
to be passed as a positonal argument:
my_series.apply(my_func, this_is_convert_dtype)
But this seems confusing and not very intuitive:
my_series.apply(my_func, this_arg_is_for_apply, this_must_be_a_tuple_with_all_args, this_is_a_single_kwarg=True, this_is_another_kwarg=False)
To me, the API would be much clear if it was implemented as:
Series.apply(func, *, convert_dtype=True, args=(), kwargs={})
# or
Series.apply(func, convert_dtype=True, *, args=(), kwargs={})
And I think this can be easily done in two steps, warning the user first without breaking code. If there is agreement, I'd also do the same for the rest of the methods using this same pattern.
holypegasus
Metadata
Metadata
Assignees
Labels
API DesignApplyApply, Aggregate, Transform, MapApply, Aggregate, Transform, MapNeeds DiscussionRequires discussion from core team before further actionRequires discussion from core team before further action