-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: Groupby with as_index=True causes incorrect summarization #34906
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: Groupby with as_index=True causes incorrect summarization #34906
Conversation
Given that this is my first commit to pandas, I'm not quite sure whether what I'm doing is what is expected. I just added the example from the bugreport as a test, is that ok? Should additional things be tested? Tested differently? Please, let me know. |
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 needs to go with other min tests, put in test_function.py but find a similar test.
pandas/tests/groupby/test_groupby.py
Outdated
) | ||
|
||
tm.assert_series_equal( | ||
df.groupby("b")["c"].min(), |
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.
pls use
result=
expected=
pandas/tests/groupby/test_groupby.py
Outdated
tm.assert_series_equal( | ||
df.groupby("b")["c"].min(), | ||
df.groupby("b", as_index=False)["c"].min()["c"], | ||
check_index_type=False, |
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.
if you have to set check_index_type or check_names the something is wrong with the expected here.
pandas/tests/groupby/test_groupby.py
Outdated
date_series = pd.Series(dates) | ||
date_series_parsed = pd.to_datetime(date_series, format="%Y-%m-%d").dt.date | ||
|
||
df = pd.DataFrame( |
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.
pls simplify this construction, e.g. directly construct the nputs
I addressed the comments, could you please have a look again? |
I don't know why there suddenly are test failures, the particular test that failed (pandas/tests/base/test_unique.py::test_unique_bad_unicode), passes on my setup and is nowhere near the test that I added. |
@vivikelapoutre can you try merging master & repushing to see if that fixes it? |
Thank you, that worked indeed. |
Thanks @vivikelapoutre! |
…s-dev#34906) * add test * PR comments * attempt to make the code cleaner
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff