-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
TYP: func argument to DataFrame.apply, DataFrame.applymap, core.apply.frame_apply #38493
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
Conversation
pandas/core/frame.py
Outdated
@@ -7656,7 +7658,13 @@ def transform( | |||
return result | |||
|
|||
def apply( | |||
self, func, axis: Axis = 0, raw: bool = False, result_type=None, args=(), **kwds | |||
self, | |||
func: ApplyFuncType, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to make it explicit, this annotation will show up as Union[np.ufunc, Union[Callable, str, List[Union[Callable, str]], Dict[Union[Hashable, NoneType], Union[Callable, str, List[Union[Callable, str]]]]]]
(kind of unreadable, IMO, but so which is not even complete yet, since the ufunc should be present in each nested case Union[Callable, str]. But isn't a ufunc a callable, so that can maybe be removed?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Going off the aggregation case we don't special case ufunc
there so we probably shouldn't do it here either.
In that case I think ApplyFuncType
is the same as AggFuncType
so we can use the same alias in both cases
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah i agree here, no need to be different, let's use AggFuncType
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
pandas/core/frame.py
Outdated
@@ -7656,7 +7658,13 @@ def transform( | |||
return result | |||
|
|||
def apply( | |||
self, func, axis: Axis = 0, raw: bool = False, result_type=None, args=(), **kwds | |||
self, | |||
func: ApplyFuncType, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah i agree here, no need to be different, let's use AggFuncType
thanks @arw2019 |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff
Spinning off from #38416, xref #38416 (comment)