-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Fix DataFrame.apply for string arg with additional args (#22376) #22377
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
BUG: Fix DataFrame.apply for string arg with additional args (#22376) #22377
Conversation
pandas/tests/frame/test_apply.py
Outdated
|
||
result = self.frame.apply(arg, axis=1) | ||
expected = getattr(self.frame, arg)(axis=1) | ||
@pytest.mark.parametrize('kwds', [{}, {'axis': 1}, {'numeric_only': True}]) |
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.
can you add a test for just std that adds both a positional arg (e.g. ddof) and a kwarg (numeric_only) for confirmation here (and other combinations if possible)
pandas/core/apply.py
Outdated
@@ -71,7 +71,8 @@ def __init__(self, obj, func, broadcast, raw, reduce, result_type, | |||
self.result_type = result_type | |||
|
|||
# curry if needed | |||
if kwds or args and not isinstance(func, np.ufunc): | |||
if (kwds or args) and not isinstance(func, (np.ufunc, |
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.
can you format this like
if ((kwds or args) and
(not isinstance.....)):
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.
@jreback The formatting you propose makes Flake complaining:
E129 visually indented line with same indent as next logical line
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.
can you also see if we have tests like this for groupby.apply
Codecov Report
@@ Coverage Diff @@
## master #22377 +/- ##
=========================================
Coverage ? 92.05%
=========================================
Files ? 169
Lines ? 50709
Branches ? 0
=========================================
Hits ? 46679
Misses ? 4030
Partials ? 0
Continue to review full report at Codecov.
|
@jreback I checked and pandas/pandas/core/groupby/groupby.py Line 676 in b5d81cf
|
thanks @megabyde |
git diff upstream/master -u -- "*.py" | flake8 --diff