-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: Fix agg ingore arg/kwargs when given list like func #50863
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 agg ingore arg/kwargs when given list like func #50863
Conversation
cc @rhshadrach, I've reworked the implementation, any suggestions for improvement? |
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.
Looks good. Could you also add an entry in the whatsnew for 2.0.0 under the bug fixes for reshaping.
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.
Looks good! Since this code is used by a variety of objects, I think some tests beyond just DataFrame should be added here.
def test__dataframe_groupy_agg_list_like_func_with_args(): | ||
# GH 50624 | ||
df = DataFrame({"x": [1, 2, 3], "y": ["a", "b", "c"]}) | ||
df = df.groupby("y") |
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 call this gb
instead; calling it df is confusing.
def test__series_groupy_agg_list_like_func_with_args(): | ||
# GH 50624 | ||
data = Series([1, 2, 3]) | ||
data = data.groupby(data) |
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.
Same.
msg = r"foo1\(\) got an unexpected keyword argument 'b'" | ||
with pytest.raises(TypeError, match=msg): | ||
df.agg([foo1, foo2], 0, 3, b=3, c=4) | ||
|
||
result = df.agg([foo1, foo2], 0, 3, c=4) |
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.
This test should be using resample.
doc/source/whatsnew/v2.0.0.rst
Outdated
@@ -1317,7 +1317,7 @@ Reshaping | |||
- Clarified error message in :func:`merge` when passing invalid ``validate`` option (:issue:`49417`) | |||
- Bug in :meth:`DataFrame.explode` raising ``ValueError`` on multiple columns with ``NaN`` values or empty lists (:issue:`46084`) | |||
- Bug in :meth:`DataFrame.transpose` with ``IntervalDtype`` column with ``timedelta64[ns]`` endpoints (:issue:`44917`) | |||
- Bug in :func:`agg` would ignore arguments when passed a list of functions (:issue:`50863`) | |||
- Bug in :meth:`DataFrame.agg`, :meth:`Series.agg`, :meth:`DataFrameGroupBy.agg`, :meth:`SeriesGroupBy.agg`, and :meth:`Resampler.agg` would ignore arguments when passed a list of functions (:issue:`50863`) |
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.
I should have mentioned - this should be split up with the groupby and resampler part going under their section within Bugfixes.
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.
lgtm
Thanks @luke396! |
This really couldn't have been done if it wasn't for your great help. |
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.Previous Pull Request #50725, for multiple elements-func list this time.
I would appreciate any feedback or suggestions on this draft pull request to help improve it. Thank you in advance for your help and cooperation.