-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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 multiindex levels equals rows #16859
Merged
jreback
merged 11 commits into
pandas-dev:master
from
P-Tillmann:bugfix_groupby_multiindex_levels_equals_rows
Aug 24, 2017
Merged
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
7928960
BUG: GH16843 fix groupby
P-Tillmann acd449f
Added whitespaces
P-Tillmann d5ec754
Added test description
P-Tillmann f34b10a
Added whats-new
P-Tillmann cd35777
Merge pull request #1 from pandas-dev/master
9404a00
removed changes from doc file
P-Tillmann 7980d79
updated whats new file (v0.21.0)
P-Tillmann 2c48282
lint fix
P-Tillmann 9af8a47
replaced inplace=True for set index in testcase, added newline at the…
P-Tillmann 50c7979
Merge branch 'master' into bugfix_groupby_multiindex_levels_equals_rows
gfyoung a98db9a
DOC: Address reviewer comments
gfyoung File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3891,6 +3891,19 @@ def predictions(tool): | |
result = df2.groupby('Key').apply(predictions).p1 | ||
tm.assert_series_equal(expected, result) | ||
|
||
def test_gb_key_len_equal_axis_len(self): | ||
# GH16843 | ||
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. can you add a 1-liner about what this is testing |
||
# test ensures that index and column keys are recognized correctly | ||
# when number of keys equals axis length of groupby | ||
df = pd.DataFrame([['foo', 'bar', 'B', 1], | ||
['foo', 'bar', 'B', 2], | ||
['foo', 'baz', 'C', 3]], | ||
columns=['first', 'second', 'third', 'one']) | ||
df = df.set_index(['first', 'second']) | ||
df = df.groupby(['first', 'second', 'third']).size() | ||
assert df.loc[('foo', 'bar', 'B')] == 2 | ||
assert df.loc[('foo', 'baz', 'C')] == 1 | ||
|
||
|
||
def _check_groupby(df, result, keys, field, f=lambda x: x.sum()): | ||
tups = lmap(tuple, df[keys].values) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Your description underneath your test I think is clearer about the bug than this description is. Try incorporating some of your test description into here.