-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: agg with axis=1 #19605
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: agg with axis=1 #19605
Conversation
…aggregate functions. Provides the user with a correct Exception for this issue.
Codecov Report
@@ Coverage Diff @@
## master #19605 +/- ##
==========================================
- Coverage 91.62% 91.62% -0.01%
==========================================
Files 150 150
Lines 48790 48804 +14
==========================================
+ Hits 44703 44715 +12
- Misses 4087 4089 +2
Continue to review full report at Codecov.
|
Hello @spencerogden! Thanks for updating the PR. Cheers ! There are no PEP8 issues in this Pull Request. 🍻 Comment last updated on February 09, 2018 at 20:51 Hours UTC |
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.
would also need a whatsnew note
@@ -1012,3 +1012,18 @@ def test_non_callable_aggregates(self): | |||
expected = df.size | |||
|
|||
assert result == expected | |||
|
|||
def test_frame_row_and_column_aggregates(self): | |||
df = DataFrame({'B': [4, 5, 6, 7, 8], |
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.
add the issue number as a comment.
df = DataFrame({'B': [4, 5, 6, 7, 8], | ||
'C': [7, 8, 9, 10, 11]}, | ||
index=[1, 2, 3, 4, 5]) | ||
|
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.
rather than just adding a new test. ideally would like to systematically test all routines.
you can create a fixture
@pytest.fixture(params=[0, 1])
def axis(request):
return request.param
assert_series_equal(df.agg('min', axis=1), | ||
Series({1: 4, | ||
2: 5, | ||
3: 6, |
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.
also add a test with mixed dtypes (note that they will generally be excluded on the agg so this works ok)
result, how = self._aggregate(func, axis=0, *args, **kwargs) | ||
result, how = self._aggregate(func, | ||
_axis=0, | ||
*args, **kwargs) |
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.
though would prefer to pass in axis and have it used down in the stack
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.
as .apply does generally work with axis=1, it is prob just not passed thru
closing in favor of #21224 |
This is a potentially inefficient fix to the this issue which requires a double transpose. I am unsure how inefficient this is, and if this is an acceptable solution. It solves the issue, but perhaps it would be preferable to implement this further down the stack in
_aggregate_multiple_funcs
.An additional small fix is to pass
_axis
down the stack.axis
was passed toself._aggregate
previous, but had not effect since it was not referenced.git diff upstream/master -u -- "*.py" | flake8 --diff