-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: groupby with no non-empty groups, #21624 #21849
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
Changes from 3 commits
3543449
eddcbd1
59b3c45
d47beea
bda628c
6d03bc9
2fd0e73
6d2855c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -782,3 +782,14 @@ def test_any_all_np_func(func): | |
|
||
res = df.groupby('key')['val'].transform(func) | ||
tm.assert_series_equal(res, exp) | ||
|
||
|
||
def test_transform_with_all_nan(): | ||
# GH 21624 | ||
df = DataFrame({'groups': [np.nan, np.nan, np.nan], | ||
'values': [1, 2, 3]}) | ||
|
||
grouped = df.groupby('groups') | ||
summed = grouped['values'].transform('sum') | ||
expected = Series([np.nan, np.nan, np.nan], name='values') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm maybe I'm missing the point but shouldn't these be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently, the behavior is to output For example, see |
||
tm.assert_series_equal(summed, expected) |
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.
Minor nit but we mostly use
result
to compare againstexpected
- can you change the variable name here and on the assertion line?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.
Sure