-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
TST: Add regression test for empty DataFrame groupby #18097
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
TST: Add regression test for empty DataFrame groupby #18097
Conversation
pandas/tests/groupby/test_groupby.py
Outdated
def test_empty_dataframe_groupby(self): | ||
# GH8093 | ||
df = pd.DataFrame(columns=['A', 'B', 'C']) | ||
assert df.groupby('A').sum().index.name == 'A' |
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.
Might as well also check that the DataFrame
that we get as a result is correct.
03e2e17
to
e5244a0
Compare
Thanks @gfyoung, fixed! |
Codecov Report
@@ Coverage Diff @@
## master #18097 +/- ##
==========================================
- Coverage 91.25% 91.23% -0.02%
==========================================
Files 163 163
Lines 50120 50120
==========================================
- Hits 45737 45728 -9
- Misses 4383 4392 +9
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #18097 +/- ##
==========================================
- Coverage 91.25% 91.23% -0.02%
==========================================
Files 163 163
Lines 50120 50120
==========================================
- Hits 45737 45728 -9
- Misses 4383 4392 +9
Continue to review full report at Codecov.
|
pandas/tests/groupby/test_groupby.py
Outdated
|
||
result = df.groupby('A').sum() | ||
expected = pd.DataFrame(columns=['B', 'C'], dtype=np.float64) | ||
expected.index.rename('A', inplace=True) |
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.
We generally discourage use of inplace
. Just use expected.index.name = 'A'
.
pandas/tests/groupby/test_groupby.py
Outdated
df = pd.DataFrame(columns=['A', 'B', 'C']) | ||
|
||
result = df.groupby('A').sum() | ||
expected = pd.DataFrame(columns=['B', 'C'], dtype=np.float64) |
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.
DataFrame
is already imported, so can remove the pd.
to make things a little cleaner
e5244a0
to
50e538e
Compare
50e538e
to
0b466e6
Compare
@gfyoung @jschendel Thanks! Fixed! |
thanks! |
git diff upstream/master -u -- "*.py" | flake8 --diff