Skip to content

BUG: Using agg with groupy, as_index=False still returning group variable as index #25114

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
wants to merge 13 commits into from

Conversation

HubertKl
Copy link
Contributor

@HubertKl HubertKl commented Feb 3, 2019

This is supposed to solve issue #25011

@codecov
Copy link

codecov bot commented Feb 3, 2019

Codecov Report

Merging #25114 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #25114   +/-   ##
=======================================
  Coverage   92.37%   92.37%           
=======================================
  Files         166      166           
  Lines       52415    52415           
=======================================
  Hits        48418    48418           
  Misses       3997     3997
Flag Coverage Δ
#multiple 90.79% <ø> (ø) ⬆️
#single 42.87% <ø> (ø) ⬆️
Impacted Files Coverage Δ
pandas/core/base.py 97.75% <ø> (ø) ⬆️

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 800d38b...cb1419b. Read the comment docs.

@codecov
Copy link

codecov bot commented Feb 3, 2019

Codecov Report

Merging #25114 into master will decrease coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #25114      +/-   ##
==========================================
- Coverage    91.9%   91.89%   -0.01%     
==========================================
  Files         175      175              
  Lines       52485    52485              
==========================================
- Hits        48234    48230       -4     
- Misses       4251     4255       +4
Flag Coverage Δ
#multiple 90.45% <ø> (ø) ⬆️
#single 40.75% <ø> (-0.14%) ⬇️
Impacted Files Coverage Δ
pandas/core/base.py 97.78% <ø> (ø) ⬆️
pandas/io/gbq.py 75% <0%> (-12.5%) ⬇️
pandas/core/frame.py 96.79% <0%> (-0.12%) ⬇️

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 a07ed59...f963b17. Read the comment docs.

@jreback jreback changed the title BUG Solving issue #25011 BUG: Using agg with groupy, as_index=False still returning group variable as index Feb 3, 2019
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.

needs test & a whatnew entry

@pep8speaks
Copy link

pep8speaks commented Feb 9, 2019

Hello @HubertKl! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2019-04-11 22:38:16 UTC

@HubertKl
Copy link
Contributor Author

Test and whatsnew entry added

@@ -170,7 +170,7 @@ Plotting
Groupby/Resample/Rolling
^^^^^^^^^^^^^^^^^^^^^^^^

-
- Bug in :method:'agg' when pqssing a list in the method agg on a Groupby with attibute as_index set as False, returned a DataFrame with the Groupby key as an index, now return the Groupby key as a column.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you make this much simpler, I am not sure what you are fixing here. add the issue number



def test_not_as_index_agg_list():

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. parameterize on as_index=[True,False]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like

@pytest.mark.parametize('as_index', [True, False]);
def test_agg_with_as_index(as_index):

....

@HubertKl
Copy link
Contributor Author

Thanks for the feedback and comments, I updated the PR accordingly.

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.

pls search for similar issues in the tracker. I am pretty sure this is actually a duplicate of 1 or more issues. We would also want to replicate those test cases here.

@@ -172,7 +172,7 @@ Plotting
Groupby/Resample/Rolling
^^^^^^^^^^^^^^^^^^^^^^^^

-
- Fixed bug in GroupBy when using as_index=False (issue:`25011`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug in ::meth:`pandas.core.groupby.GroupBy.aggwhen passingas_index=False``, returning an additional column.



def test_not_as_index_agg_list():

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like

@pytest.mark.parametize('as_index', [True, False]);
def test_agg_with_as_index(as_index):

....

@jreback
Copy link
Contributor

jreback commented Mar 20, 2019

can you merge master

@WillAyd
Copy link
Member

WillAyd commented Apr 10, 2019

@HubertKl can you merge master and fix up conflicts?

@WillAyd
Copy link
Member

WillAyd commented May 3, 2019

Closing as stale but would certainly like this. Let us know if you'd like to pick it back up @HubertKl !

@WillAyd WillAyd closed this May 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using agg with groupy, as_index=False still returning group variable as index
4 participants