-
-
Notifications
You must be signed in to change notification settings - Fork 141
DataFrame.apply
stub doesn't reflect default value of axis
parameter
#393
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
Comments
The trick here is that the function So for your example to work, it would have to change, and we have to add an overload for |
Dr-Irv, |
I think (but not 100% sure) that the comment about |
Based on some experimenting, that's correct. If the passed function returns a scalar, apply() will create a Series. If the function returns something list-like, apply() will create a DataFrame. But I think the underlying problem here may be a bit different. None of the overloads allows for an args param with no axis param. |
We need to have a new overload, where the return type is based on whether the function |
* Series.value_counts returns Series[int]. * Series.apply callable result might not be hashable It's possible for the callable in Series.apply to return something non-hashable like a list, but the result of apply should still be a Series. * More detailed typing for DataFrame.apply. Whether it returns a Series or a DataFrame depends on the return type of the callable. In the case of the callable returning a scalar, the result is a Series unless the result_type is "broadcast". * Add test for #393.
fixed in #401 |
Describe the bug
If you call
DataFrame.apply
and pass parameters beyondf
but not includingaxis
, you'll get the following error from Pyright:To Reproduce
Pylance gives the following error on the
apply
call:Please complete the following information:
pandas-stubs
: 1.5.0.220926Additional context
Originally reported by @jonmooser at microsoft/pylance-release#3491
I was originally thinking that the fix was to indicate in the stubs that
axis
has a default value (axis: AxisType = ...
), but then the two overloads ofapply
overlap with each other. It was looking like the correct fix would require more knowledge of the innards ofapply
and Pandas in general than I have.The text was updated successfully, but these errors were encountered: