-
-
Notifications
You must be signed in to change notification settings - Fork 19.2k
BUG: Validate numeric_only parameter in groupby aggregations #62842
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
base: main
Are you sure you want to change the base?
Changes from 4 commits
52e07b5
b2f18ef
9655a9a
6ef5696
5a72c79
8056bb8
63f8443
bb9b0ab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -86,6 +86,7 @@ class providing the base-class of operations. | |
| is_object_dtype, | ||
| is_scalar, | ||
| is_string_dtype, | ||
| is_bool, | ||
| needs_i8_conversion, | ||
| pandas_dtype, | ||
| ) | ||
|
|
@@ -1754,7 +1755,10 @@ def _cython_agg_general( | |
| **kwargs, | ||
| ): | ||
| # Note: we never get here with how="ohlc" for DataFrameGroupBy; | ||
| # that goes through SeriesGroupBy | ||
| # that goes through SeriesGroupBy | ||
|
||
|
|
||
| if not is_bool(numeric_only): | ||
| raise ValueError("numeric_only accepts only Boolean values") | ||
|
|
||
| data = self._get_data_to_aggregate(numeric_only=numeric_only, name=how) | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1520,3 +1520,27 @@ def test_groupby_std_datetimelike(): | |||||||||||
| exp_ser = Series([td1 * 2, td1, td1, td1, td4], index=np.arange(5)) | ||||||||||||
| expected = DataFrame({"A": exp_ser, "B": exp_ser, "C": exp_ser}) | ||||||||||||
| tm.assert_frame_equal(result, expected) | ||||||||||||
|
|
||||||||||||
| def test_mean_numeric_only_validates_bool(): | ||||||||||||
| """ | ||||||||||||
| Test that numeric_only parameter only accepts boolean values. | ||||||||||||
| See GH#62778 | ||||||||||||
| """ | ||||||||||||
|
||||||||||||
| """ | |
| Test that numeric_only parameter only accepts boolean values. | |
| See GH#62778 | |
| """ | |
| # GH#62778 |
Outdated
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 remove this comment, it repeats the code.
Outdated
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 remove these; the test suite has many tests for numeric_only being specified or not specified, these are not increasing our test coverage.
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.
So should I remove this whole function from the test file or just these 3 lines of code?
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 these four lines.
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.
@rhshadrach Made the suggested changes. I had made the changes in the comment inside groupby.py file but forgot to add it while doing git add, hence, it didn't show up in the changes here.
This version should be fine. Please let me know if any other changes are there.
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.
Only mention public things in the whatsnew. Also "Boolean-valued inputs" makes it sounds like there was an issue with
TrueandFalse.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.
Sure, let me correct that.
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.
@rhshadrach Made the required changes!