`DataFrame.apply` stub doesn't reflect default value of `axis` parameter
See original GitHub issueDescribe the bug
If you call DataFrame.apply
and pass parameters beyond f
but not including axis
, you’ll get the following error from Pyright:
No overloads for "apply" match the provided arguments
To Reproduce
import pandas as pd
def gethead(s, y):
return s.head(y)
df = pd.DataFrame({"A": [1, 2, 3, 4, 5, 6], "B": [11, 12, 13, 14, 15, 16]})
df2 = df.apply(gethead, args=tuple([4])) # error
Pylance gives the following error on the apply
call:
No overloads for "apply" match the provided arguments
Argument types: ((s: Unknown, y: Unknown) -> Unknown, tuple[int, ...])Pylance[reportGeneralTypeIssues](https://github.com/microsoft/pylance-release/blob/main/DIAGNOSTIC_SEVERITY_RULES.md#diagnostic-severity-rules)
Please complete the following information:
- OS: Windows
- OS Version: 10.0.25197 Build 25197
- python version: 3.10.0
- version of type checker: Pylance 2022.10.21
- version of installed
pandas-stubs
: 1.5.0.220926
Additional context Originally reported by @jonmooser at https://github.com/microsoft/pylance-release/issues/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 of apply
overlap with each other. It was looking like the correct fix would require more knowledge of the innards of apply
and Pandas in general than I have.
Issue Analytics
- State:
- Created a year ago
- Comments:6
Top Results From Across the Web
Dataframe apply doesn't accept axis argument - Stack Overflow
So far I am trying to perform an apply function that will return me this structure, but the dataframe apply is not accepting...
Read more >Why isn't my Pandas .apply working? Try axis=1 - Medium
What's going on here? The default for .apply is axis=0. axis=0, pass the df index to the function; axis=1, pass the ...
Read more >What's New — pandas 0.23.0 documentation - PyData |
DataFrame.apply() was inconsistent when applying an arbitrary user-defined-function that returned a list-like with axis=1 . Several bugs and inconsistencies ...
Read more >Pandas DataFrame apply() Examples - DigitalOcean
axis : axis along which the function is applied. The possible values are {0 or 'index', 1 or 'columns'}, default 0. args: The...
Read more >SWAT USER GROUP
changed land use and soil maps and tested all changes in parameters ... instance, my initial N-S for winter flow was 0.64 with...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
fixed in #401
We need to have a new overload, where the return type is based on whether the function
f
isCallable[..., ScalarT]
orCallable[..., list-like]
, wherelist-like
is appropriately defined.