Skip to content

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

Closed

Conversation

spencerogden
Copy link

@spencerogden spencerogden commented Feb 8, 2018

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 to self._aggregate previous, but had not effect since it was not referenced.

@codecov
Copy link

codecov bot commented Feb 8, 2018

Codecov Report

Merging #19605 into master will decrease coverage by <.01%.
The diff coverage is 85.71%.

Impacted file tree graph

@@            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
Flag Coverage Δ
#multiple 89.99% <85.71%> (-0.01%) ⬇️
#single 41.72% <0%> (-0.01%) ⬇️
Impacted Files Coverage Δ
pandas/core/frame.py 97.33% <85.71%> (-0.1%) ⬇️
pandas/io/formats/format.py 96.25% <0%> (+0.01%) ⬆️
pandas/core/arrays/base.py 60.6% <0%> (+3.93%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b835127...054a13a. Read the comment docs.

@pep8speaks
Copy link

pep8speaks commented Feb 9, 2018

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

Copy link
Contributor

@jreback jreback left a 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],
Copy link
Contributor

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])

Copy link
Contributor

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,
Copy link
Contributor

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)
Copy link
Contributor

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

Copy link
Contributor

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

@jreback jreback added Bug Reshaping Concat, Merge/Join, Stack/Unstack, Explode labels Feb 10, 2018
@jreback jreback changed the title Agg method issue 16679 BUG: agg with axis=1 Feb 10, 2018
@jreback
Copy link
Contributor

jreback commented Jul 7, 2018

closing in favor of #21224

@jreback jreback closed this Jul 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants